-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoClicker.py
82 lines (68 loc) · 2.13 KB
/
AutoClicker.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import time
import mouse
import keyboard
import random
import threading
import sys
import signal
from wx.adv import TaskBarIcon
from wx import App, Icon
isOn = False
isOn2 = False
wxApp = App()
print("Welcome to AutoClicker 2000 !")
print("And use CTRL + C to stop.")
keyLeft = input("Enter the key you want to use to toggle on or off the left autoclicker: ")
keyRight = input("Enter the key you want to use to toggle on or off the right autoclicker: ")
calcClickPerSeconds = 1 / int(input("Enter the number of CPS you want: "))
def update_icon():
global taskbarIcon, isOn, isOn2
if not isOn and not isOn2:
taskbarIcon.SetIcon(Icon("images/not_used.ico"), "AutoClicker2000")
if isOn and not isOn2:
taskbarIcon.SetIcon(Icon("images/used_left.ico"), "AutoClicker2000")
if not isOn and isOn2:
taskbarIcon.SetIcon(Icon("images/used_right.ico"), "AutoClicker2000")
if isOn and isOn2:
taskbarIcon.SetIcon(Icon("images/used_both.ico"), "AutoClicker2000")
def signal_handler(sig, frame):
print("Stopping program...")
taskbarIcon.Destroy()
sys.exit(0)
def lcThread():
global isOn
time_ = time.time()
while isOn:
while not time.time()>=time_+calcClickPerSeconds:
pass
mouse.click('left')
time_ = time_ + calcClickPerSeconds
def rcThread():
global isOn2
time_ = time.time()
while isOn2:
while not time.time()>=time_+calcClickPerSeconds:
pass
mouse.click('right')
time_ = time_ + calcClickPerSeconds
def tryLc(val):
global isOn
isOn = not isOn
update_icon()
if isOn:
lcThreadOb = threading.Thread(target=lcThread)
lcThreadOb.start()
def tryRc(val):
global isOn2
isOn2 = not isOn2
update_icon()
if isOn2:
rcThreadOb = threading.Thread(target=rcThread)
rcThreadOb.start()
keyboard.on_press_key(key=keyLeft, callback=tryLc)
keyboard.on_press_key(key=keyRight, callback=tryRc)
signalevent = signal.signal(signal.SIGINT, signal_handler)
taskbarIcon = TaskBarIcon()
taskbarIcon.SetIcon(Icon("images/not_used.ico"), "AutoClicker2000")
while True:
time.sleep(60)