|
| 1 | +import time |
| 2 | +import threading |
| 3 | +from pynput.mouse import Button, Controller |
| 4 | +from pynput.keyboard import Listener, KeyCode |
| 5 | +import os |
| 6 | + |
| 7 | +divider = "————————————————————————————————————————————————————————" |
| 8 | + |
| 9 | +try: |
| 10 | + clicks = float(input("Delay speed: (Default: 0.060 Seconds ~ 15 Clicks Per Second): ")) |
| 11 | + delay = clicks |
| 12 | +except ValueError: |
| 13 | + clicks = 0.060 |
| 14 | + delay = clicks |
| 15 | + |
| 16 | +print(divider) |
| 17 | + |
| 18 | +# ——————————————————————————————————————————————————————— |
| 19 | +# ——————————————————————————————————————————————————————— |
| 20 | +# ——————————————————————————————————————————————————————— |
| 21 | + |
| 22 | +input_start_and_stop_key = str(input("Start And Stop Key: (Default: x): ")) |
| 23 | +start_stop_key = KeyCode(char=input_start_and_stop_key) |
| 24 | + |
| 25 | +if input_start_and_stop_key == "": |
| 26 | + start_stop_key = KeyCode(char="x") |
| 27 | + |
| 28 | +print(divider) |
| 29 | + |
| 30 | +# ——————————————————————————————————————————————————————— |
| 31 | +# ——————————————————————————————————————————————————————— |
| 32 | +# ——————————————————————————————————————————————————————— |
| 33 | + |
| 34 | +input_exit_key = str(input("Exit Key: (Default: `): ")) |
| 35 | +exit_key = KeyCode(char=input_exit_key) |
| 36 | + |
| 37 | +if input_exit_key == "": |
| 38 | + exit_key = KeyCode(char="`") |
| 39 | + |
| 40 | +print(divider) |
| 41 | + |
| 42 | +# ——————————————————————————————————————————————————————— |
| 43 | +# ——————————————————————————————————————————————————————— |
| 44 | +# ——————————————————————————————————————————————————————— |
| 45 | + |
| 46 | +input_button = str(input("Options: Left, Right, Middle" |
| 47 | + "\nMouse button: (Default: Left Mouse Button): ")) |
| 48 | +input_button = input_button.lower() |
| 49 | +button = Button.left |
| 50 | + |
| 51 | +if input_button == "right": |
| 52 | + button = Button.right |
| 53 | +elif input_button == "middle": |
| 54 | + button = Button.middle |
| 55 | +else: |
| 56 | + pass |
| 57 | + |
| 58 | +print(divider) |
| 59 | + |
| 60 | +# ——————————————————————————————————————————————————————— |
| 61 | +# ——————————————————————————————————————————————————————— |
| 62 | +# ——————————————————————————————————————————————————————— |
| 63 | + |
| 64 | + |
| 65 | +class ClickMouse(threading.Thread): |
| 66 | + def __init__(self, delay, button): |
| 67 | + super(ClickMouse, self).__init__() |
| 68 | + self.delay = delay |
| 69 | + self.button = button |
| 70 | + self.running = False |
| 71 | + self.program_running = True |
| 72 | + |
| 73 | + def start_clicking(self): |
| 74 | + self.running = True |
| 75 | + |
| 76 | + def stop_clicking(self): |
| 77 | + self.running = False |
| 78 | + |
| 79 | + def exit(self): |
| 80 | + self.stop_clicking() |
| 81 | + self.program_running = False |
| 82 | + |
| 83 | + def run(self): |
| 84 | + while self.program_running: |
| 85 | + while self.running: |
| 86 | + mouse.click(self.button) |
| 87 | + time.sleep(self.delay) |
| 88 | + time.sleep(0.1) |
| 89 | + |
| 90 | + |
| 91 | +# ——————————————————————————————————————————————————————— |
| 92 | +# ——————————————————————————————————————————————————————— |
| 93 | +# ——————————————————————————————————————————————————————— |
| 94 | + |
| 95 | + |
| 96 | +mouse = Controller() |
| 97 | +click_thread = ClickMouse(delay, button) |
| 98 | +click_thread.start() |
| 99 | + |
| 100 | + |
| 101 | +print("Clicker is ready!") |
| 102 | + |
| 103 | +# ——————————————————————————————————————————————————————— |
| 104 | +# ——————————————————————————————————————————————————————— |
| 105 | +# ——————————————————————————————————————————————————————— |
| 106 | + |
| 107 | + |
| 108 | +def on_press(key): |
| 109 | + if key == start_stop_key: |
| 110 | + if click_thread.running: |
| 111 | + click_thread.stop_clicking() |
| 112 | + os.system("clear") |
| 113 | + print("Clicking as stopped!") |
| 114 | + print(divider) |
| 115 | + else: |
| 116 | + click_thread.start_clicking() |
| 117 | + os.system("clear") |
| 118 | + print("Clicking as started!") |
| 119 | + print(divider) |
| 120 | + elif key == exit_key: |
| 121 | + click_thread.exit() |
| 122 | + listener.stop() |
| 123 | + |
| 124 | + |
| 125 | +with Listener(on_press=on_press) as listener: |
| 126 | + listener.join() |
0 commit comments