本文整理汇总了Python中Quartz.kCGEventMouseMoved方法的典型用法代码示例。如果您正苦于以下问题:Python Quartz.kCGEventMouseMoved方法的具体用法?Python Quartz.kCGEventMouseMoved怎么用?Python Quartz.kCGEventMouseMoved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quartz
的用法示例。
在下文中一共展示了Quartz.kCGEventMouseMoved方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGEventMouseMoved [as 别名]
def __init__(self, callback):
self.callback = callback
self.is_recording = False
self.thread = None
self.event_tap = Quartz.CGEventTapCreate(
Quartz.kCGSessionEventTap,
Quartz.kCGHeadInsertEventTap,
Quartz.kCGEventTapOptionDefault,
Quartz.CGEventMaskBit(Quartz.kCGEventKeyDown) |
Quartz.CGEventMaskBit(Quartz.kCGEventKeyUp) |
Quartz.CGEventMaskBit(Quartz.kCGEventFlagsChanged) |
Quartz.CGEventMaskBit(Quartz.kCGEventLeftMouseDown) |
Quartz.CGEventMaskBit(Quartz.kCGEventLeftMouseUp) |
Quartz.CGEventMaskBit(Quartz.kCGEventRightMouseDown) |
Quartz.CGEventMaskBit(Quartz.kCGEventRightMouseUp) |
Quartz.CGEventMaskBit(Quartz.kCGEventOtherMouseDown) |
Quartz.CGEventMaskBit(Quartz.kCGEventOtherMouseUp) |
Quartz.CGEventMaskBit(Quartz.kCGEventMouseMoved) |
Quartz.CGEventMaskBit(Quartz.kCGEventScrollWheel),
self.event_handler,
None
)
示例2: move
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGEventMouseMoved [as 别名]
def move(self, x, y):
self.__mouse_event(Quartz.kCGEventMouseMoved, x, y)
Quartz.CGWarpMouseCursorPosition((x, y))
示例3: move_rel
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGEventMouseMoved [as 别名]
def move_rel(self, x, y):
[x, y] = self.torelative(x, y)
moveEvent = Quartz.CGEventCreateMouseEvent(None, Quartz.kCGEventMouseMoved, Quartz.CGPointMake(x, y), 0)
Quartz.CGEventPost(Quartz.kCGHIDEventTap, moveEvent)
示例4: _moveTo
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGEventMouseMoved [as 别名]
def _moveTo(x, y):
_sendMouseEvent(Quartz.kCGEventMouseMoved, x, y, 0)
time.sleep(0.01) # needed to allow OS time to catch up.
示例5: move
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGEventMouseMoved [as 别名]
def move(x, y):
move = Quartz.CGEventCreateMouseEvent(None, Quartz.kCGEventMouseMoved, (x, y), 0)
Quartz.CGEventPost(Quartz.kCGHIDEventTap, move)
示例6: _position_set
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGEventMouseMoved [as 别名]
def _position_set(self, pos):
try:
(_, _, mouse_type), mouse_button = self._drag_button.value
except AttributeError:
mouse_type = Quartz.kCGEventMouseMoved
mouse_button = 0
Quartz.CGEventPost(
Quartz.kCGHIDEventTap,
Quartz.CGEventCreateMouseEvent(
None,
mouse_type,
pos,
mouse_button))
示例7: _handle
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGEventMouseMoved [as 别名]
def _handle(self, dummy_proxy, event_type, event, dummy_refcon):
"""The callback registered with *Mac OSX* for mouse events.
This method will call the callbacks registered on initialisation.
"""
try:
(px, py) = Quartz.CGEventGetLocation(event)
except AttributeError:
# This happens during teardown of the virtual machine
return
# Quickly detect the most common event type
if event_type == Quartz.kCGEventMouseMoved:
self.on_move(px, py)
elif event_type == Quartz.kCGEventScrollWheel:
dx = Quartz.CGEventGetIntegerValueField(
event,
Quartz.kCGScrollWheelEventDeltaAxis2)
dy = Quartz.CGEventGetIntegerValueField(
event,
Quartz.kCGScrollWheelEventDeltaAxis1)
self.on_scroll(px, py, dx, dy)
else:
for button in Button:
try:
(press, release, drag), _ = button.value
except TypeError:
# Button.unknown cannot be enumerated
continue
# Press and release generate click events, and drag
# generates move events
if event_type in (press, release):
self.on_click(px, py, button, event_type == press)
elif event_type == drag:
self.on_move(px, py)