-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastAutoClicker.py
More file actions
54 lines (43 loc) · 1.24 KB
/
FastAutoClicker.py
File metadata and controls
54 lines (43 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import time
import threading
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode
print("press 's' to start clicking")
delay = 0.001
button = Button.left
start_stop_key = KeyCode(char='s')
exit_key = KeyCode(char='e')
class ClickMouse(threading.Thread):
def __init__(self, delay, button):
super(ClickMouse, self).__init__()
self.delay = delay
self.button = button
self.running = False
self.program_run = True
def start_clicking(self):
self.running = True
def stop_clicking(self):
self.running = False
def exit(self):
self.stop_clicking()
self.program_run = False
def run(self):
while self.program_run:
while self.running:
mouse.click(self.button)
time.sleep(self.delay)
time.sleep(0.1)
mouse = Controller()
thread = ClickMouse(delay, button)
thread.start()
def on_press(key):
if key == start_stop_key:
if thread.running:
thread.stop_clicking()
else:
thread.start_clicking()
elif key == exit_key:
thread.exit()
listener.stop()
with Listener(on_press=on_press) as listener:
listener.join()