Skip to content

Instantly share code, notes, and snippets.

@lkaihua
Last active July 5, 2021 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkaihua/40fefc512d2b2b01c31dd80f2f53995d to your computer and use it in GitHub Desktop.
Save lkaihua/40fefc512d2b2b01c31dd80f2f53995d to your computer and use it in GitHub Desktop.
A simple mouse mover
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!')
@lkaihua
Copy link
Author

lkaihua commented Jul 5, 2021

pip install pyautogui
pip install keyboard
sudo python mouse-mover.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment