本文整理匯總了Python中pyatspi.Registry.generateMouseEvent方法的典型用法代碼示例。如果您正苦於以下問題:Python Registry.generateMouseEvent方法的具體用法?Python Registry.generateMouseEvent怎麽用?Python Registry.generateMouseEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyatspi.Registry
的用法示例。
在下文中一共展示了Registry.generateMouseEvent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: absoluteMotionWithTrajectory
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def absoluteMotionWithTrajectory(source_x, source_y, dest_x, dest_y, mouseDelay=None, check=True):
"""
Synthetize mouse absolute motion with trajectory. The 'trajectory' means that the whole motion
is divided into several atomic movements which are synthetized separately.
"""
if check:
checkCoordinates(source_x, source_y)
checkCoordinates(dest_x, dest_y)
logger.log("Mouse absolute motion with trajectory to (%s,%s)" % (dest_x, dest_y))
dx = float(dest_x - source_x)
dy = float(dest_y - source_y)
max_len = max(abs(dx), abs(dy))
if max_len == 0:
# actually, no motion requested
return
dx /= max_len
dy /= max_len
act_x = float(source_x)
act_y = float(source_y)
for _ in range(0, int(max_len)):
act_x += dx
act_y += dy
if mouseDelay:
doDelay(mouseDelay)
registry.generateMouseEvent(int(act_x), int(act_y), name='abs')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()
示例2: relativeMotion
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def relativeMotion(x, y, mouseDelay=None):
logger.log("Mouse relative motion of (%s,%s)" % (x, y))
registry.generateMouseEvent(x, y, 'rel')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()
示例3: mouse_event
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def mouse_event(x, y, button, eventType):
"""
> Description
Generates a mouse press or release event on a specific pixel on the screen
> Parameters
x (int): the x coordinate where the event will be generated
y (int): the y coordinate where the event will be generated
button (str): A string indicating which mouse button to press/release. One of 'left', 'right' or 'middle'
eventType (str): A string indicating the event type. One of 'press' or 'release'
> Returns
None
> Example
# this example could demonstrate a drag and drop of a file
# press the left mouse button at 100, 100
Macro.mouse_event(100, 100, 'left', 'press')
# move the cursor to 400, 400
Macro.move_cursor_to(400, 400)
# then, release the mouse
Macro.mouse_event(400, 400, 'left', 'press')
"""
buttonToNo = {'left':1, 'right':2, 'middle':3 }
controller.generateMouseEvent(x, y, 'b' + str(buttonToNo[button]) + ('p' if eventType == 'press' else 'r'))
示例4: doubleClick
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def doubleClick(x, y, button=1, check=True):
"""
Synthesize a mouse button double-click at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s doubleclick at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, 'b%sd' % button)
doDelay()
示例5: press
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def press(x, y, button=1, check=True):
"""
Synthesize a mouse button press at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s press at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, name='b%sp' % button)
doDelay()
示例6: release
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def release(x, y, button=1, check=True):
"""
Synthesize a mouse button release at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s release at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, 'b%sr' % button)
doDelay()
示例7: click
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def click(x, y, button=1, check=True):
"""
Synthesize a mouse button click at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s click at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, 'b%sc' % button)
doDelay(config.actionDelay)
示例8: relativeMotion
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def relativeMotion(x, y, mouseDelay=None):
"""
Synthetize a relative motion from actual position.
Note: Does not check if the end coordinates are positive.
"""
logger.log("Mouse relative motion of (%s,%s)" % (x, y))
registry.generateMouseEvent(x, y, name='rel')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()
示例9: absoluteMotion
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def absoluteMotion(x, y, mouseDelay=None, check=True):
"""
Synthesize mouse absolute motion to (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse absolute motion to (%s,%s)" % (x, y))
registry.generateMouseEvent(x, y, 'abs')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()
示例10: move_cursor_to
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def move_cursor_to(x, y):
"""
> Description
Moves the cursor to the x, y coordinates
> Parameters
x (int): the x coordinate to move the cursor to
y (int): the y coordinate to move the cursor to
> Returns
None
> Example
# move the cursor to 100, 100
Macro.move_cursor_to(100, 100)
"""
controller.generateMouseEvent(x, y, MOUSE_ABS)
示例11: right_click_to
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def right_click_to(x, y):
"""
> Description
Right clicks the mouse at x, y
> Parameters
x (int): the x coordinate to right click to
y (int): the y coordinate to right click to
> Returns
None
> Example
# right click to 100, 100
Macro.right_click_to(100, 100)
"""
if(x >= 0 and y >= 0):
controller.generateMouseEvent(x, y, 'b3c')
示例12: middle_click_to
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def middle_click_to(x, y):
"""
> Description
Middle clicks the mouse at x, y
> Parameters
x (int): the x coordinate to middle click to
y (int): the y coordinate to middle click to
> Returns
None
> Example
# middle click to 100, 100
Macro.middle_click_to(100, 100)
"""
if(x >= 0 and y >= 0):
controller.generateMouseEvent(x, y, 'b2c')
示例13: move_cursor_to
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def move_cursor_to(self, x, y):
"""Moves the cursor to the x, y coordinates"""
controller.generateMouseEvent(x, y, MOUSE_ABS)
示例14: right_click_to
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def right_click_to(self, x, y):
"""Right clicks the cursor to the x, y coordinates"""
if x >= 0 and y >= 0:
controller.generateMouseEvent(x, y, "b3c")
示例15: double_click
# 需要導入模塊: from pyatspi import Registry [as 別名]
# 或者: from pyatspi.Registry import generateMouseEvent [as 別名]
def double_click(self, button = 1):
self.widow_hide()
x,y = self.get_center()
registry.generateMouseEvent(x, y, 'b%sd' % button)