Advertisement
mauricioribeiro

Robot Moving Cursor

Aug 17th, 2020
4,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import pyautogui, time
  2.  
  3. print(pyautogui.size())
  4. print(pyautogui.position())
  5.  
  6. w, h = pyautogui.size()
  7. center, seconds, direction, boundary = (w / 2, h / 2), 5, -1, 200
  8. pyautogui.moveTo(center)
  9.  
  10. print('Robot running... Press Ctrl-C to quit.')
  11. try:
  12.     i = 1
  13.     while True:
  14.         x, y = pyautogui.position()
  15.  
  16.         if i > 1:
  17.             direction *= -1
  18.             i = 0
  19.  
  20.         pyautogui.move(0, boundary * direction, seconds)
  21.         time.sleep(seconds)
  22.         i += 1
  23.  
  24. except KeyboardInterrupt:
  25.     print('\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement