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


Python pyautogui.moveRel方法代码示例

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


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

示例1: test_moveRelWithTween

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import moveRel [as 别名]
def test_moveRelWithTween(self):
        origin = self.center - P(100, 100)
        delta = P(200, 200)
        destination = origin + delta

        def resetMouse():
            pyautogui.moveTo(*origin)
            mousepos = P(*pyautogui.position())
            self.assertEqual(mousepos, origin)

        for tweenName in self.TWEENS:
            tweenFunc = getattr(pyautogui, tweenName)
            resetMouse()
            pyautogui.moveRel(delta.x, delta.y, duration=pyautogui.MINIMUM_DURATION * 2, tween=tweenFunc)
            mousepos = P(*pyautogui.position())
            self.assertEqual(
                mousepos,
                destination,
                "%s tween move failed. mousepos set to %s instead of %s" % (tweenName, mousepos, destination),
            ) 
开发者ID:asweigart,项目名称:pyautogui,代码行数:22,代码来源:test_pyautogui.py

示例2: make_busy

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import moveRel [as 别名]
def make_busy():
    """Moves mouse every 10 seconds to keep apps active
    Args:
        None
    Returns:
        None
    """
    print('Press CTRL-C to quit.')
    try:
        while True:
            pyautogui.moveRel(5, 0, 0.5)
            pyautogui.moveRel(-5, 0, 0.5)
            time.sleep(10)
    except KeyboardInterrupt:
        print('Process has quit...') 
开发者ID:kudeh,项目名称:automate-the-boring-stuff-projects,代码行数:17,代码来源:look_busy.py

示例3: test_pause

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import moveRel [as 别名]
def test_pause(self):
        oldValue = pyautogui.PAUSE

        startTime = time.time()
        pyautogui.PAUSE = 0.35  # there should be a 0.35 second pause after each call
        pyautogui.moveTo(1, 1)
        pyautogui.moveRel(0, 1)
        pyautogui.moveTo(1, 1)

        elapsed = time.time() - startTime
        self.assertTrue(1.0 < elapsed < 1.1, "Took %s seconds, expected 1.0 < 1.1 seconds." % (elapsed))

        pyautogui.PAUSE = oldValue  # restore the old PAUSE value 
开发者ID:asweigart,项目名称:pyautogui,代码行数:15,代码来源:test_pyautogui.py

示例4: test_moveRel

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import moveRel [as 别名]
def test_moveRel(self):
        # start at the center
        desired = self.center
        pyautogui.moveTo(*desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move down and right
        desired += P(42, 42)
        pyautogui.moveRel(42, 42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move up and left
        desired -= P(42, 42)
        pyautogui.moveRel(-42, -42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move right
        desired += P(42, 0)
        pyautogui.moveRel(42, 0)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move down
        desired += P(0, 42)
        pyautogui.moveRel(0, 42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move left
        desired += P(-42, 0)
        pyautogui.moveRel(-42, 0)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move up
        desired += P(0, -42)
        pyautogui.moveRel(0, -42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a list instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel([42, 42])
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a tuple instead of separate x and y.
        desired -= P(42, 42)
        pyautogui.moveRel((-42, -42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a sequence-like object instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel(P(42, 42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired) 
开发者ID:asweigart,项目名称:pyautogui,代码行数:62,代码来源:test_pyautogui.py


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