本文整理汇总了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),
)
示例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...')
示例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
示例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)