From abfdd15b84b3e864a81e4040ee26fc8ced56f5fc Mon Sep 17 00:00:00 2001 From: Noa Fabbricotti Date: Sun, 30 Nov 2025 17:34:38 +0000 Subject: [PATCH] Add main.py --- main.py | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..02b2b82 --- /dev/null +++ b/main.py @@ -0,0 +1,62 @@ +# Imports and all that + +import pynput, time + +Button = pynput.mouse.Button +Key = pynput.keyboard.Key +Listener = pynput.keyboard.Listener +mouse = pynput.mouse.Controller() + +# Variable handling + +def safeToInt(var): + try: + return int(var) + except Exception as e: + print(e) + exit(1) + +def safeToFloat(var): + try: + return float(var) + except Exception as e: + print(e) + exit(1) + +count = safeToInt(input("Amount of clicks: ")) +timeout = safeToFloat(input("Enter a timeout in seconds: ")) +stopKey = input('Stop key: ') +button = input('LMB, MMB or RMD: ') + +# Actual input simulation + +stop = False + +def on_press(key): + global stop + if hasattr(key, 'char') and key.char == stopKey: + stop = True + return False + +Listener(on_press=on_press).start() + +if(button == 'LMB'): + if stop: + exit(1) + for x in range(count): + mouse.click(Button.left, 1) + time.sleep(timeout) + +if(button == 'MMB'): + if stop: + exit(1) + for x in range(count): + mouse.click(Button.left, 1) + time.sleep(timeout) + +if(button == 'RMB'): + if stop: + exit(1) + for x in range(count): + mouse.click(Button.left, 1) + time.sleep(timeout) \ No newline at end of file