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


Python Registry.generateMouseEvent方法代码示例

本文整理汇总了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()
开发者ID:martiinsiimon,项目名称:dogtail,代码行数:34,代码来源:rawinput.py

示例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()
开发者ID:Lorquas,项目名称:dogtail,代码行数:9,代码来源:rawinput.py

示例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'))
开发者ID:hakermania,项目名称:MacroPolo,代码行数:28,代码来源:macropolo.py

示例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()
开发者ID:Lorquas,项目名称:dogtail,代码行数:11,代码来源:rawinput.py

示例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()
开发者ID:martiinsiimon,项目名称:dogtail,代码行数:11,代码来源:rawinput.py

示例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()
开发者ID:Lorquas,项目名称:dogtail,代码行数:11,代码来源:rawinput.py

示例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)
开发者ID:Lorquas,项目名称:dogtail,代码行数:11,代码来源:rawinput.py

示例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()
开发者ID:martiinsiimon,项目名称:dogtail,代码行数:13,代码来源:rawinput.py

示例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()
开发者ID:Lorquas,项目名称:dogtail,代码行数:14,代码来源:rawinput.py

示例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)
开发者ID:hakermania,项目名称:MacroPolo,代码行数:19,代码来源:macropolo.py

示例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')
开发者ID:hakermania,项目名称:MacroPolo,代码行数:20,代码来源:macropolo.py

示例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')
开发者ID:hakermania,项目名称:MacroPolo,代码行数:20,代码来源:macropolo.py

示例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)
开发者ID:om-nomnom,项目名称:MacroPolo,代码行数:5,代码来源:macropolo.py

示例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")
开发者ID:om-nomnom,项目名称:MacroPolo,代码行数:6,代码来源:macropolo.py

示例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)
开发者ID:3demax,项目名称:Clicky,代码行数:6,代码来源:main.py


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