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.

38 lines
1.1 KiB

7 years ago
  1. import psutil
  2. import pyautogui as send_input
  3. import subprocess
  4. import os
  5. CLICKER_START_COM = os.path.expandvars('"%userprofile%\Documents\clickerP.exe" 20')
  6. class clicker_manager:
  7. def __init__(self):
  8. self.proc_id = None
  9. for process in psutil.process_iter():
  10. if process.name() == 'clickerP.exe':
  11. self.proc_id = process.pid
  12. break
  13. print(self.proc_id)
  14. if self.proc_id is None:
  15. self.proc_id = subprocess.Popen(CLICKER_START_COM).pid
  16. self.on = False
  17. def toggle(self):
  18. send_input.press('tab')
  19. self.on = not self.on
  20. def turn_off(self):
  21. if self.on:
  22. self.toggle()
  23. def turn_on(self):
  24. if not self.on:
  25. self.toggle()
  26. def kill(self):
  27. try:
  28. proc = psutil.Process(self.proc_id)
  29. for sub_proc in proc.children(recursive=True):
  30. sub_proc.kill()
  31. proc.kill()
  32. except psutil.NoSuchProcess:
  33. pass
  34. if __name__ == "__main__":
  35. test = clicker_manager()