-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmonster_clicker.ahk
208 lines (162 loc) · 4.33 KB
/
monster_clicker.ahk
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
; -----------------------------------------------------------------------------------------------------
; Clicker Heroes Monster Clicker
; by Sw1ftb
; Hotkeys:
; Shift+F1 to start
; Shift+F2 to pause
; Shift+F3 to stop
; Shift+F5 to reload the script (needed after configuration changes)
; Shift+F6 to re-initialize coordinates (needed after moving or re-sizing the client window)
; Pause to Pause/unpause the script
; Ctrl+Esc to Suspend/Unsuspend all other Hotkeys
; Built in click speed throttle when moving mouse cursor inside the Clicker Heroes window.
; -----------------------------------------------------------------------------------------------------
#Persistent
#NoEnv
#InstallKeybdHook
#SingleInstance force
#Include %A_ScriptDir%
#Include ch_bot_lib.ahk
SetControlDelay, -1
SetBatchLines, -1
scriptName=Monster Clicker
scriptVersion=1.4
minLibVersion=4.0
script := scriptName . " v" . scriptVersion
tag := "[Clicker] "
short := 21 ; ms
long := 2000 ; throttled delay
clickDelay := short
keepOnClicking := false
; -----------------------------------------------------------------------------------------
#Include system\wm_messages.ahk
; Load system default settings
#Include system\monster_clicker_default_settings.ahk
IfNotExist, monster_clicker_settings.ahk
{
FileCopy, system\monster_clicker_default_settings.ahk, monster_clicker_settings.ahk
}
#Include *i monster_clicker_settings.ahk
if (libVersion < minLibVersion) {
showWarningSplash(tag . "The bot lib version must be " . minLibVersion . " or higher!")
ExitApp
}
logVariable("script", script)
clientCheck()
OnMessage(WM_CLICKER_START, "MsgMonitor")
OnMessage(WM_CLICKER_PAUSE, "MsgMonitor")
OnMessage(WM_CLICKER_STOP, "MsgMonitor")
OnMessage(WM_CLICKER_STATUS, "MsgMonitor")
OnMessage(WM_CLICKER_RELOAD, "MsgMonitor")
OnMessage(WM_CLICKER_INITIALIZE, "MsgMonitor")
OnMessage(WM_CLICKER_MODE_FAST, "MsgMonitor")
OnMessage(WM_CLICKER_MODE_SLOW, "MsgMonitor")
; -----------------------------------------------------------------------------------------
; -- Hotkeys (+=Shift)
; -----------------------------------------------------------------------------------------
+F1::
clickerStart()
return
+F2::
clickerPause()
return
+F3::
clickerStop()
return
+F5::
clickerReload()
return
+F6::
clickerInitialize()
return
; Pause/unpause the script
~Pause::Pause
return
; Suspend/Unsuspend all other Hotkeys with Ctrl+Esc
~^Esc::Suspend, Toggle
return
clickerStart() {
global
keepOnClicking := true
local monsterClicks := 0
local startTime := A_TickCount
showSplash(tag . "Start")
if (clickDuration > 0) {
setTimer, stopClicking, % -clickDuration * 60 * 1000 ; run only once
}
setTimer, checkMouse, 250
while(keepOnClicking) {
clickPos(xMonster, yMonster)
monsterClicks++
sleep % clickDelay
}
setTimer, checkMouse, off
local elapsedTime := (A_TickCount - startTime) / 1000
local clicksPerSecond := round(monsterClicks / elapsedTime, 2)
showSplash(tag . "Duration: " . formatSeconds(elapsedTime) . ", CPS: " . clicksPerSecond)
}
clickerPause() {
global
critical
if (keepOnClicking) {
msgbox,,% script,Click safety pause engaged. Continue?
}
}
clickerStop() {
global
keepOnClicking := false
}
clickerStatus() {
global
return keepOnClicking
}
clickerReload() {
showUserSplash(tag . "Script Reload", 1)
Reload
}
clickerInitialize() {
clientCheck()
}
clickerModeFast() {
global
clickDelay := short
}
clickerModeSlow() {
global
clickDelay := long
}
MsgMonitor(wParam, lParam, msg) {
if (msg = WM_CLICKER_START) {
clickerStart()
} else if (msg = WM_CLICKER_PAUSE) {
clickerPause()
} else if (msg = WM_CLICKER_STOP) {
clickerStop()
} else if (msg = WM_CLICKER_STATUS) {
return clickerStatus()
} else if (msg = WM_CLICKER_RELOAD) {
clickerReload()
} else if (msg = WM_CLICKER_INITIALIZE) {
clickerInitialize()
} else if (msg = WM_CLICKER_MODE_FAST) {
setTimer, checkMouse, on
clickerModeFast()
} else if (msg = WM_CLICKER_MODE_SLOW) {
setTimer, checkMouse, off
clickerModeSlow()
}
}
; -----------------------------------------------------------------------------------------
; -- Subroutines
; -----------------------------------------------------------------------------------------
checkMouse:
MouseGetPos,,, window
if (window = WinExist(winName)) {
clickerModeSlow()
} else {
clickerModeFast()
}
return
stopClicking:
keepOnClicking := false
return