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.
44 lines
1.2 KiB
44 lines
1.2 KiB
import psutil
|
|
import pyautogui as send_input
|
|
import subprocess
|
|
import os
|
|
CLICKER_PATH = os.path.expandvars(r"%local_repo%\other\toggler\clicker.exe")
|
|
CLICKER_START_COM = [CLICKER_PATH,'20']
|
|
class clicker_manager:
|
|
def __init__(self):
|
|
self.proc_id = None
|
|
for process in psutil.process_iter():
|
|
if process.name() == 'clickerP.exe':
|
|
self.proc_id = process.pid
|
|
break
|
|
print(self.proc_id)
|
|
if self.proc_id is None:
|
|
self.proc_id = subprocess.Popen(CLICKER_START_COM).pid
|
|
self.on = False
|
|
def toggle(self):
|
|
send_input.press('tab')
|
|
self.on = not self.on
|
|
|
|
def turn_off(self):
|
|
if self.on:
|
|
self.toggle()
|
|
|
|
|
|
def turn_on(self):
|
|
if not self.on:
|
|
self.toggle()
|
|
|
|
def kill(self):
|
|
try:
|
|
proc = psutil.Process(self.proc_id)
|
|
for sub_proc in proc.children(recursive=True):
|
|
sub_proc.kill()
|
|
proc.kill()
|
|
except psutil.NoSuchProcess:
|
|
pass
|
|
|
|
def update(self):
|
|
self.on = os.path.exists(os.path.join(os.path.dirname(CLICKER_PATH),'on'))
|
|
|
|
if __name__ == "__main__":
|
|
test = clicker_manager()
|