當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。