-
-
Save alecordev/d7e6b0a1f86131a60f29792e5a4aafec to your computer and use it in GitHub Desktop.
Simple mouse example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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