当前位置: 首页>>代码示例>>Python>>正文


Python NSEvent.mouseLocation方法代码示例

本文整理汇总了Python中AppKit.NSEvent.mouseLocation方法的典型用法代码示例。如果您正苦于以下问题:Python NSEvent.mouseLocation方法的具体用法?Python NSEvent.mouseLocation怎么用?Python NSEvent.mouseLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppKit.NSEvent的用法示例。


在下文中一共展示了NSEvent.mouseLocation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mouseLocation

# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import mouseLocation [as 别名]
def mouseLocation(isTopCoordinates = True):
	if (isTopCoordinates):
		mLoc = getMouseLoc()
		return (mLoc.x,mLoc.y)
	else:
		mLoc = NSEvent.mouseLocation()
		return (mLoc.x,mLoc.y)
开发者ID:natewalck,项目名称:pymaCursor,代码行数:9,代码来源:pymaCursor.py

示例2: __init__

# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import mouseLocation [as 别名]
 def __init__(self, ns_event):
     self._ns_event = ns_event
     _ns_type = ns_event.type()
     kind = _ns_event_type_to_kind[_ns_type]
     self.kind = kind
     self.time = ns_event.timestamp()
     ns_window = ns_event.window()
     is_mouse_event = kind in _mouse_events
     if is_mouse_event:
         ns_win_pos = ns_event.locationInWindow()
         x, y = ns_window.convertBaseToScreen_(ns_win_pos)
     else:
         ns_last_mouse = Globals.ns_last_mouse_moved_event
         if ns_last_mouse:
             ns_window = ns_last_mouse.window()
             if ns_window:
                 ns_win_pos = ns_last_mouse.locationInWindow()
                 x, y = ns_window.convertBaseToScreen_(ns_win_pos)
             else:
                 x, y = ns_last_mouse.locationInWindow()
         else:
             x, y = NSEvent.mouseLocation()
     h = Globals.ns_screen_height
     self.global_position = (x, h - y)
     if is_mouse_event:
         self.button = _ns_event_type_to_button.get(_ns_type, '')
         if kind == 'mouse_down':
             self.num_clicks = ns_event.clickCount()
         self.delta = (ns_event.deltaX(), ns_event.deltaY())
     ns_flags = ns_event.modifierFlags()
     self.shift = self.extend_contig = (ns_flags & NSShiftKeyMask) <> 0
     self.control = (ns_flags & NSControlKeyMask) <> 0
     self.command = self.extend_noncontig = (ns_flags & NSCommandKeyMask) <> 0
     self.option = (ns_flags & NSAlternateKeyMask) <> 0
     if kind in _key_events:
         self.auto = ns_event.isARepeat()
         ns_chars = ns_event.characters()
         #print "Event.__init__: ns_chars =", repr(ns_chars) ###
         self.unichars = ns_chars
         if len(ns_chars) == 1:
             if ns_chars == "\x19" and ns_event.keyCode() == 48:
                 self.char = "\t"
             elif ns_chars == "\x7f":
                 self.char = "\x08"
             elif ns_chars <= "\x7e":
                 self.char = str(ns_chars)
             #else:
             #	self.char = ns_chars
         ns_unmod = ns_event.charactersIgnoringModifiers()
         key = _ns_keycode_to_keyname.get(ns_chars, '')
         if not key and u"\x20" <= ns_unmod <= u"\x7e":
             key = str(ns_unmod)
         self.key = key
         if key == 'enter':
             self.char = "\r"
         elif key == 'delete':
             self.char = "\x7f"
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:59,代码来源:Event.py

示例3: position

# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import mouseLocation [as 别名]
 def position(self):
     loc = NSEvent.mouseLocation()
     return loc.x, Quartz.CGDisplayPixelsHigh(0) - loc.y
开发者ID:Kruelt,项目名称:PyUserInput,代码行数:5,代码来源:mac.py

示例4: getPosition

# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import mouseLocation [as 别名]
 def getPosition(self):
     loc = NSEvent.mouseLocation()
     return (loc.x, CGDisplayPixelsHigh(0) - loc.y)
开发者ID:mart-e,项目名称:I-m-Human,代码行数:5,代码来源:MouseMac.py

示例5: _position_get

# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import mouseLocation [as 别名]
    def _position_get(self):
        pos = NSEvent.mouseLocation()

        return pos.x, Quartz.CGDisplayPixelsHigh(0) - pos.y
开发者ID:leandrobrunner,项目名称:pynput,代码行数:6,代码来源:_darwin.py

示例6: CGWindowListCopyWindowInfo

# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import mouseLocation [as 别名]
else:
    pid = None
    while 1:
        app = NSWorkspace.sharedWorkspace().activeApplication()
        if pid != app['NSApplicationProcessIdentifier']:
            pid = app['NSApplicationProcessIdentifier']
            winList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly,
                                                 kCGNullWindowID)
            activeWin = None
            for win in winList:
                # print 'win:', win
                if win['kCGWindowOwnerPID'] == pid and \
                   win['kCGWindowAlpha'] != 0 and win['kCGWindowLayer'] == 0:
                    print win
                    activeWin = win
                    break
            if activeWin:
                bounds = activeWin['kCGWindowBounds']
                loc = NSEvent.mouseLocation()
                loc.y = 1080 - loc.y # this might need to be tweaked depending on layout of displays
                print (app['NSApplicationName'], bounds['X'], bounds['Y'], bounds['Width'], bounds['Height']), (loc.x, loc.y)
                if loc.x < bounds['X'] or loc.x >= bounds['X'] + bounds['Width'] or \
                   loc.y < bounds['Y'] or loc.y >= bounds['Y'] + bounds['Height']:
                    x = bounds['X'] + bounds['Width']/2
                    y = bounds['Y'] + bounds['Height']/2
                    print 'move to', (x, y)
                    mousemove(x, y)

        time.sleep(0.2)

开发者ID:crackleware,项目名称:osx-tools,代码行数:31,代码来源:cursor-auto-recenter-agent.py

示例7: position

# 需要导入模块: from AppKit import NSEvent [as 别名]
# 或者: from AppKit.NSEvent import mouseLocation [as 别名]
	def position():
		loc = NSEvent.mouseLocation()
		return Point(loc.x, CGDisplayPixelsHigh(0) - loc.y)
开发者ID:jBugman,项目名称:clicker,代码行数:5,代码来源:mac.py


注:本文中的AppKit.NSEvent.mouseLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。