-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclicker.py
More file actions
63 lines (50 loc) · 1.69 KB
/
clicker.py
File metadata and controls
63 lines (50 loc) · 1.69 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
55
56
57
58
59
60
61
62
63
import random
import threading
import time
import pynput.keyboard
from pynput.mouse import Button, Controller
class ClickMouse(threading.Thread):
def __init__(self, cps=60, button=Button.left, clicktime=0, burst=1):
super(ClickMouse, self).__init__()
self.cps = cps
self.delay = 1 / cps
if button == "right":
self.button = Button.right
elif button == "middle":
self.button = Button.middle
else:
self.button = Button.left
self.running = False
self.program_running = True
self.ct = clicktime
self.burst = burst
self.mouse = Controller()
self.start()
def toggle(self):
if self.running:
print("Stopping... ")
self.running = False
else:
print(f"Starting... ({self.cps} CPS {self.button})")
self.running = True
def exit(self):
self.running = False
self.program_running = False
def getBurst(self):
return random.uniform(-0.9, 0.5) * self.burst * self.delay
def run(self):
while self.program_running:
if self.ct == 0:
while self.running:
self.mouse.click(self.button)
time.sleep(self.delay + self.getBurst())
else:
if self.running:
for i in range(self.ct):
for i in range(self.cps):
self.mouse.click(self.button)
time.sleep(self.delay + self.getBurst())
self.running = False
time.sleep(0.1)
if __name__ == "__main__":
click_thread = ClickMouse()