Last active
July 5, 2021 22:50
-
-
Save lkaihua/40fefc512d2b2b01c31dd80f2f53995d to your computer and use it in GitHub Desktop.
A simple mouse mover
This file contains hidden or 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 pyautogui | |
import keyboard | |
import random | |
import time | |
pyautogui.FAILSAFE = True | |
if __name__ == '__main__': | |
while True: | |
print('Press Key 1 to start!') | |
keyboard.wait('1') | |
while keyboard.is_pressed('esc') == False: | |
x = int(500 * random.random()) | |
y = int(500 * random.random()) | |
pyautogui.moveTo(x, y, duration=0.5, tween=pyautogui.easeInOutQuad) | |
print(f'Press Key Esc to stop! Move to {x}, {y}') | |
time.sleep(1) | |
if keyboard.is_pressed('esc'): | |
print('\nDetect that key Esc is pressed and stops!') |
Author
lkaihua
commented
Jul 5, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment