-
Notifications
You must be signed in to change notification settings - Fork 37
/
NIAutoclicker.ahk
243 lines (220 loc) · 5.4 KB
/
NIAutoclicker.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
;Non-Intrusive Autoclicker, by Shadowspaz
;v2.1.1
#InstallKeybdHook
#SingleInstance, Force
DetectHiddenWindows, on
SetControlDelay -1
SetBatchLines -1
Thread, Interrupt, 0
SetFormat, float, 0.0
toggle := false
inputPresent := false
mouseMoved := false
settingPoints := false
clickRate := 20
Mode := 0
pmx := 0
pmy := 0
totalClicks := 1
currentClick := 1
TempRateCPS := 50
TempRateSPC := 1
setTimer, checkMouseMovement, 10
setTimer, setTip, 5
TTStart = %A_TickCount%
while (A_TickCount - TTStart < 5000 && !toggle)
{
TooltipMsg = Press (Alt + Backspace) to toggle autoclicker `n Press (Alt + Dash(-)) for options
}
TooltipMsg =
!-::
IfWinNotExist, NIAC Settings
{
if settingPoints
{
toggle := false
settingPoints := false
actWin :=
TooltipMsg =
}
prevTC := totalClicks
Gui, Show, w210 h160, NIAC Settings
Gui, Add, Radio, x25 y10 gActEdit1 vmode, Clicks per second:
Gui, Add, Radio, x25 y35 gActEdit2, Seconds per click:
Gui, Add, Edit, x135 y8 w50 Number Left vtempRateCPS, % tempRateCPS
Gui, Add, Edit, x135 y33 w50 Number Left vtempRateSPC, % tempRateSPC
Gui, Add, Text, x30 y65, Total click locations:
Gui, Add, Edit, x133 y63 w50 Number Left vtotalClicks, % totalClicks
Gui, Add, Text, x0 w210 0x10
Gui, Add, Text, x27 y100, (Default is 50 clicks per second)
Gui, Add, Button, x60 y117 gReset, Reset
Gui, Add, Button, x112 y117 Default gSetVal, Set
Gui, Font, s6
Gui, Add, Text, x188 y151, v2.1.1
if mode < 2
{
GuiControl,, Mode, 1
GoSub, ActEdit1
}
else
{
GuiControl,, Seconds per click:, 1
GoSub, ActEdit2
}
}
else
WinActivate, NIAC Settings
return
ActEdit1:
GuiControl, Enable, tempRateCPS
GuiControl, Disable, tempRateSPC
GuiControl, Focus, tempRateCPS
Send +{End}
return
ActEdit2:
GuiControl, Enable, tempRateSPC
GuiControl, Disable, tempRateCPS
GuiControl, Focus, tempRateSPC
Send +{End}
return
Reset:
toggle := false
actWin :=
setTimer, autoClick, off
currentClick := 1
GuiControl, Disable, Reset
Gui, Font, s8
Gui, Add, Text, x54 y145, Click locations reset.
return
SetVal:
Gui, Submit
if mode < 2
clickRate := tempRateCPS > 0 ? 1000 / tempRateCPS : 1000
else
clickRate := tempRateSPC > 0 ? 1000 * tempRateSPC : 1000
if totalClicks != %prevTC%
{
toggle := false
actWin :=
setTimer, autoClick, off
}
GuiClose:
if toggle
{
EmptyMem()
setTimer, autoclick, %clickRate%
}
Gui, Destroy
return
!Backspace::
IfWinNotExist, NIAC Settings ; Only functional if options window is not open
{
toggle := !toggle
if toggle
{
setTimer, setTip, 5
if (!actWin) ; actWin value is also used to determine if checks are set. If they aren't:
{
settingPoints := true ; Used to allow break if options are opened
Loop, %totalClicks%
{
if totalClicks < 2
TooltipMsg = Click the desired autoclick location.
else
TooltipMsg = Click the location for point %A_Index%.
toggle := false
Keywait, LButton, D
Keywait, LButton
if !settingPoints ; Opening options sets this to false, breaking the loop
return
TooltipMsg =
newIndex := A_Index - 1
MouseGetPos, xp%newIndex%, yp%newIndex%
WinGet, actWin, ID, A
}
settingPoints := false
}
else ; If values ARE set (actWin contains data):
{
settingPoints := false
setTimer, setTip, 5
TTStart = %A_TickCount%
TooltipMsg = ##Autoclick enabled.
}
toggle := true
EmptyMem()
setTimer, autoclick, %clickRate%
}
else
{
setTimer, setTip, 5
TTStart = %A_TickCount%
TooltipMsg = ##Autoclick disabled.
setTimer, autoclick, off
}
}
return
setTip:
StringReplace, cleanTTM, TooltipMsg, ##
Tooltip, % cleanTTM
if (InStr(TooltipMsg, "##") && A_TickCount - TTStart > 1000)
TooltipMsg =
if TooltipMsg =
{
Tooltip
setTimer, setTip, off
}
return
checkMouseMovement:
if (WinExist("ahk_id" . actWin) || !actWin) ; If NIAC is clicking in a window, or the window isn't set, it's all good.
{
MouseGetPos, tx, ty
if (tx == pmx && ty == pmy)
mouseMoved := false
else
mouseMoved := true
pmx := tx
pmy := ty
}
else ; Otherwise, the target window has been closed.
{
Msgbox, 4, NIAC, Target window has been closed, `n Do you want to close NIAutoclicker as well?
IfMsgBox Yes
ExitApp
else
{
actWin :=
toggle := false
}
}
return
autoclick:
if !(WinActive("ahk_id" . actWin) && (A_TimeIdlePhysical < 50 && !mouseMoved))
{
cx := xp%currentClick%
cy := yp%currentClick%
ControlClick, x%cx% y%cy%, ahk_id %actWin%,,,, NA
currentClick := % Mod(currentClick + 1, totalClicks)
}
return
~*LButton up::
return
#If WinActive("ahk_id" . actWin) && toggle
$~*LButton::
MouseGetPos,,, winClick
if winClick = %actWin%
setTimer, autoclick, off
Send {Blind}{LButton Down}
return
$~*LButton up::
IfWinNotExist, NIAC Settings
setTimer, autoclick, %clickRate%
Send {Blind}{LButton Up}
return
EmptyMem()
{
pid:= DllCall("GetCurrentProcessId")
h:=DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", pid)
DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1)
DllCall("CloseHandle", "Int", h)
}