Skip to content

Instantly share code, notes, and snippets.

@alecordev
Created October 3, 2017 15:41
Show Gist options
  • Save alecordev/d7e6b0a1f86131a60f29792e5a4aafec to your computer and use it in GitHub Desktop.
Save alecordev/d7e6b0a1f86131a60f29792e5a4aafec to your computer and use it in GitHub Desktop.
Simple mouse example
import time
import logging
import pyautogui
logging.basicConfig(level=logging.DEBUG,
format='[%(asctime)s] - %(message)s')
pyautogui.FAILSAFE = False
pyautogui.PAUSE = 2.5
def run(*args, **kwargs):
wait_time = kwargs.get('wait_time', 30)
while 1:
mouse_x, mouse_y = pyautogui.position()
logging.info('Position: x={} y={}'.format(mouse_x, mouse_y))
pyautogui.moveTo(mouse_x + 10, mouse_y + 10, duration=2)
new_x, new_y = pyautogui.position()
logging.info('Position: x={} y={}'.format(new_x, new_y))
pyautogui.moveTo(mouse_x, mouse_y, duration=2)
logging.info('Waiting for {}'.format(wait_time))
time.sleep(wait_time)
if __name__ == '__main__':
run(wait_time=30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment