You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
372 B

11 months ago
  1. import time
  2. import ctypes
  3. from pynput.keyboard import Key
  4. from pynput.keyboard import Controller
  5. a=0
  6. while True:
  7. if ctypes.windll.user32.GetForegroundWindow() == 0:
  8. print('0')
  9. time.sleep(2)
  10. else:
  11. a = a+1
  12. b = Controller()
  13. b.press(Key.f20)
  14. b.release(Key.f20)
  15. time.sleep(30)
  16. print('1')
  17. print(a)