-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurAutomatonV0.1.au3
445 lines (352 loc) · 12.5 KB
/
urAutomatonV0.1.au3
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <StringConstants.au3>
#include <File.au3>
;urAutomaton
;Author: Ferhat Tohidi Far
Opt("GUIOnEventMode" , 1);event mode: ACTIVATED
; Add hotkeys
HotKeySet("+1", "addLeft")
HotKeySet("+2", "addRight")
HotKeySet("+a", "addLetterKey")
HotKeySet("+b", "addLetterKey")
HotKeySet("+c", "addLetterKey")
HotKeySet("+d", "addLetterKey")
HotKeySet("+e", "addLetterKey")
HotKeySet("+f", "addLetterKey")
HotKeySet("+g", "addLetterKey")
HotKeySet("+h", "addLetterKey")
HotKeySet("+i", "addLetterKey")
HotKeySet("+j", "addLetterKey")
HotKeySet("+k", "addLetterKey")
HotKeySet("+l", "addLetterKey")
HotKeySet("+m", "addLetterKey")
HotKeySet("+n", "addLetterKey")
HotKeySet("+o", "addLetterKey")
HotKeySet("+p", "addLetterKey")
HotKeySet("+q", "addLetterKey")
HotKeySet("+r", "addLetterKey")
HotKeySet("+s", "addLetterKey")
HotKeySet("+t", "addLetterKey")
HotKeySet("+u", "addLetterKey")
HotKeySet("+v", "addLetterKey")
HotKeySet("+w", "addLetterKey")
HotKeySet("+x", "addLetterKey")
HotKeySet("+y", "addLetterKey")
HotKeySet("+z", "addLetterKey")
HotKeySet("+3", "repeat")
HotKeySet("+4", "Pause")
HotKeySet("+5", "resetStack")
HotKeySet("{Esc}", "Quit")
; Quits the program
Func Quit()
SetStatus("QUIT")
GUIDelete()
Exit
EndFunc
Global $pause = true
; Helper to pause the program
Func Pause()
if $pause then
$pause = false
GUICtrlSetBkColor($s4, 0xFF0000)
SetStatus("stopped!")
Sleep(100)
GUICtrlSetBkColor($s4, 0xFFFFFF)
EndIf
EndFunc
; GUI CODE
$meinGui = GUICreate("urAutomaton (Stack)", 700, 500)
GUISetBkColor(0xAAAAAA)
; Left side
$statusLabel = GUICtrlCreateLabel("status information:", 10, 10, 390, 20)
GUICtrlSetBkColor($statusLabel, 0x00AAFF)
GUICtrlSetColor($statusLabel, 0x000000)
Global $ctrl_status = GuiCtrlCreateInput("instructions see below!", 10, 40,390, 30)
GUICtrlSetBkColor($ctrl_status, 0x777777)
GUICtrlSetColor($ctrl_status, 0xFFFFFF)
; statusbox function
Func SetStatus( $msg )
GUICtrlSetData( $ctrl_status, $msg )
EndFunc
$red = GUICtrlCreateLabel("Control keys: ", 10, 280, 390)
GUICtrlSetBkColor($red, 0x00EEFF)
$s1 = GUICtrlCreateLabel("Shift + 1 to register left click on current mouse position! ", 10, 300, 390)
$s2 = GUICtrlCreateLabel("Shift + 2 to register right click on current mouse position! ", 10, 320, 390)
$s3 = GUICtrlCreateLabel("Shift + 3 to play the stack. ", 10, 340, 390)
$s4 = GUICtrlCreateLabel("Shift + 4 to stop the stack. ", 10, 360, 390)
$s5 = GUICtrlCreateLabel("Shift + (a-z) to register a letter key to be pressed", 10, 380, 390)
$s6 = GUICtrlCreateLabel("PC option activates PixelChecksum and checks for different pixels", 10, 400, 390)
$s7 = GUICtrlCreateLabel("on click position since you saved your click. If pixels changed->no click! ", 10, 420, 390)
GUICtrlSetBkColor($s1, 0xFFFFFF)
GUICtrlSetBkColor($s2, 0xFFFFFF)
GUICtrlSetBkColor($s3, 0xFFFFFF)
GUICtrlSetBkColor($s4, 0xFFFFFF)
GUICtrlSetBkColor($s5, 0xFFFFFF)
GUICtrlSetBkColor($s6, 0x00EEFF)
GUICtrlSetBkColor($s7, 0x00EEFF)
;profile save and load buttons
$profileSave = GUICtrlCreateButton("Save profile", 95, 240, 80)
GUICtrlSetBkColor($profileSave, 0x00AAFF)
GUICtrlSetColor($profileSave, 0x000000)
GUICtrlSetOnEvent($profileSave, "createProfile")
$profileLoad = GUICtrlCreateButton("Load profile", 175, 240, 80)
GUICtrlSetBkColor($profileLoad, 0x00AAFF)
GUICtrlSetColor($profileLoad, 0x000000)
GUICtrlSetOnEvent($profileLoad, "loadProfile")
Func createProfile()
$i = 0
;$NewFilePath = @ScriptDir & "\profile.txt" ;New file path defined
$NewFilePath = FileOpenDialog("Choose save directory and filename", @ScriptDir, "Text files (*.txt)")
While $i <= $index
$n = 0
While $n <= 2
if $i < $index then
FileWriteLine($NewFilePath, ($stack[$i])[$n])
EndIf
$n = $n + 1
WEnd
$i = $i + 1
WEnd
EndFunc
Func loadProfile()
$i = 1
resetStack()
;$OldFilePath = @ScriptDir & "\profile.txt" ;Old file path defined
$OldFilePath = FileOpenDialog("Choose profile file -> .txt", @ScriptDir, "Text files (*.txt)")
While $i <= _FileCountLines($OldFilePath)
$n = 0
Local $tempArray[3]
While $n <= 2
if(FileReadLine($OldFilePath, $i)="0") Then
$tempArray[$n] = 0
ElseIf(FileReadLine($OldFilePath, $i)="1") Then
$tempArray[$n] = 1
Else
$tempArray[$n] = FileReadLine($OldFilePath, $i) ;Read the line
EndIf
$n = $n + 1
$i = $i + 1
WEnd
$stack[$index] = $tempArray
if $tempArray[2] == 0 then
$labelStack[$index] = GUICtrlCreateListViewItem($tempArray[0] & "|" & $tempArray[1] & "|" & "left click" , $idListview)
elseif $tempArray[2] == 1 then
$labelStack[$index] = GUICtrlCreateListViewItem($tempArray[0] & "|" & $tempArray[1] & "|" & "right click" , $idListview)
else
$labelStack[$index] = GUICtrlCreateListViewItem($tempArray[0] & "|" & $tempArray[1] & "|" & $tempArray[2] , $idListview)
EndIf
$index = $index + 1
WEnd
EndFunc
;checker
Global $checker = GUICtrlCreateCheckbox("Pixel check toggle (PC)", 10, 450)
Global $enableChecker
Global $pCH[100]
Func pixelCheck()
$pCH[$index] = PixelChecksum(MouseGetPos(0)-3,MouseGetPos(1)-3, MouseGetPos(0)+3, MouseGetPos(1)+3)
EndFunc
Func pixelCheckRunTime()
MouseMove(($stack[$hilfeRepeat])[0], ($stack[$hilfeRepeat])[1], 1)
$a = PixelChecksum(MouseGetPos(0)-3,MouseGetPos(1)-3, MouseGetPos(0)+3, MouseGetPos(1)+3)
$b = $pCH[$hilfeRepeat]
SetStatus($a & " " & $b)
if $a = $b Then
return True
Else
return False
EndIf
EndFunc
; User input area
GUICtrlCreateLabel("Repeat stack ... times", 10, 80)
Global $wieOft = GuiCtrlCreateInput("1", 10, 100,390, 30)
GUICtrlCreateLabel("Delay between actions?", 10, 130)
Global $clickDelay = GuiCtrlCreateInput("10", 10, 150,390, 30)
GUICtrlCreateLabel("Delay between stack replays?", 10, 180)
Global $repeatDelay = GuiCtrlCreateInput("10", 10, 200,390, 30)
; Stack variables
Global $stack[1000]
Global $index = 0
Global $labelStack[1000]
; Global variables
Global $boolean = false
Global $hilfeRepeat = 0
;RESET BUTTON
$resetButton = GUICtrlCreateButton("Reset stack", 10, 240, 80)
GUICtrlSetBkColor($resetButton, 0x00AAFF)
GUICtrlSetColor($resetButton, 0x000000)
GUICtrlSetOnEvent($resetButton, "resetStack")
Func resetStack()
SetStatus("Reset started")
While $index > 0
GuiCtrlDelete($labelStack[$index])
$index = $index - 1
GuiCtrlDelete($labelStack[$index])
WEnd
GuiCtrlSetState($checker, $GUI_ENABLE)
SetStatus("Reset complete")
EndFunc
; ListView side
Global $idListview = GUICtrlCreateListView("X coord | Y coord | action ", 420, 50, 240, 402)
$lab = GUICtrlCreateLabel("your stack:", 420, 10, 240)
GUICtrlSetBkColor($lab, 0x00AAFF)
GUICtrlSetColor($lab, 0x000000)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
While 1
WEnd
;<BotPart>
Func addLeft()
GUICtrlSetBkColor($s1, 0x00AAFF)
$x = MouseGetPos(0)
$y = MouseGetPos(1)
if GUICtrlRead($checker) = $GUI_CHECKED then
pixelCheck()
$enableChecker = false
EndIf
GuiCtrlSetState($checker, $GUI_DISABLE)
Local $internalArray[3] = [$x, $y, 0]
$stack[$index] = $internalArray
$labelStack[$index] = GUICtrlCreateListViewItem($internalArray[0] & "|" & $internalArray[1] & "|left" , $idListview)
$index = $index +1
SetStatus("X Position " & $internalArray[0] & " Y Position " & $internalArray[1] & " left click")
_GUICtrlListView_Scroll($idListview, 0, 20)
GUICtrlSetBkColor($s1, 0xFFFFFF)
EndFunc
Func addRight()
GUICtrlSetBkColor($s2, 0x00AAFF)
$x = MouseGetPos(0)
$y = MouseGetPos(1)
if GUICtrlRead($checker) = $GUI_CHECKED then
pixelCheck()
$enableChecker = false
EndIf
GuiCtrlSetState($checker, $GUI_DISABLE)
Local $internalArray[3] = [$x, $y, 1]
$stack[$index] = $internalArray
$labelStack[$index] = GUICtrlCreateListViewItem($internalArray[0] & "|" & $internalArray[1] & "|right" , $idListview)
$index = $index +1
SetStatus("X Position " & $internalArray[0] & " Y Position " & $internalArray[1] & " right click")
_GUICtrlListView_Scroll($idListview, 0, 20)
GUICtrlSetBkColor($s2, 0xFFFFFF)
EndFunc
Func addLetterKey()
Local $pressedKey = ""
GUICtrlSetBkColor($s5, 0x00AAFF)
Switch @HotKeyPressed
Case "+a"
$pressedKey = "a"
Case "+b"
$pressedKey = "b"
Case "+c"
$pressedKey = "c"
Case "+d"
$pressedKey = "d"
Case "+e"
$pressedKey = "e"
Case "+f"
$pressedKey = "f"
Case "+g"
$pressedKey = "g"
Case "+h"
$pressedKey = "h"
Case "+i"
$pressedKey = "i"
Case "+j"
$pressedKey = "j"
Case "+k"
$pressedKey = "k"
Case "+l"
$pressedKey = "l"
Case "+m"
$pressedKey = "m"
Case "+n"
$pressedKey = "n"
Case "+o"
$pressedKey = "o"
Case "+p"
$pressedKey = "p"
Case "+q"
$pressedKey = "q"
Case "+r"
$pressedKey = "r"
Case "+s"
$pressedKey = "s"
Case "+t"
$pressedKey = "t"
Case "+u"
$pressedKey = "u"
Case "+v"
$pressedKey = "v"
Case "+w"
$pressedKey = "w"
Case "+x"
$pressedKey = "x"
Case "+y"
$pressedKey = "y"
Case "+z"
$pressedKey = "z"
EndSwitch
Local $internalArray[3] = ["-", "-", $pressedKey]
$stack[$index] = $internalArray
SetStatus("Pressed Key: " & ($stack[$index])[2])
$labelStack[$index] = GUICtrlCreateListViewItem($internalArray[0] & "|" & $internalArray[1] & "|" & $pressedKey , $idListview)
$index = $index +1
_GUICtrlListView_Scroll($idListview, 0, 20)
GUICtrlSetBkColor($s5, 0xFFFFFF)
EndFunc
Func repeat()
$pause = true
GuiCtrlSetState($checker, $GUI_DISABLE)
GUICtrlSetBkColor($s3, 0xFF0000)
$hilfeRepeat = 0
$von = 0
$bis = GUICtrlRead($wieOft)
While $von < $bis AND $pause
_GUICtrlListView_Scroll($idListview, 0, -2000)
While $hilfeRepeat < $index AND $pause
SetStatus("Action number: " & $hilfeRepeat & " Replay number: (" & $von+1 & "/" & $bis & ") ")
if IsString(($stack[$hilfeRepeat])[2]) = 1 Then;send key:char
GuiCtrlSetBkColor($labelStack[$hilfeRepeat], 0xFFFFFF)
_GUICtrlListView_Scroll($idListview, 0, 20)
SetStatus("Sending Key: " & ($stack[$hilfeRepeat])[2] )
Send("" & ($stack[$hilfeRepeat])[2]);important part
GuiCtrlSetBkColor($labelStack[$hilfeRepeat], 0x00AAFF)
EndIf
if Not IsString(($stack[$hilfeRepeat])[2]) = 1 Then
if GUICtrlRead($checker) = $GUI_CHECKED Then;if pixelcheck is activated
if ($stack[$hilfeRepeat])[2] = 0 AND pixelCheckRunTime() = True Then
MouseClick("left", ($stack[$hilfeRepeat])[0], ($stack[$hilfeRepeat])[1], 1, 0);important part
GuiCtrlSetBkColor($labelStack[$hilfeRepeat], 0x00AAFF)
EndIf
if ($stack[$hilfeRepeat])[2] = 1 AND pixelCheckRunTime() = true Then
MouseClick("right", ($stack[$hilfeRepeat])[0], ($stack[$hilfeRepeat])[1], 1, 0);important part
GuiCtrlSetBkColor($labelStack[$hilfeRepeat], 0x00AAFF)
EndIf
Else;if pixelcheck is not activated
if ($stack[$hilfeRepeat])[2] = 0 Then;left click
MouseClick("left", ($stack[$hilfeRepeat])[0], ($stack[$hilfeRepeat])[1], 1, 0);important part
GuiCtrlSetBkColor($labelStack[$hilfeRepeat], 0x00AAFF)
EndIf
if ($stack[$hilfeRepeat])[2] = 1 Then;right click
MouseClick("right", ($stack[$hilfeRepeat])[0], ($stack[$hilfeRepeat])[1], 1, 0);important part
GuiCtrlSetBkColor($labelStack[$hilfeRepeat], 0x00AAFF)
EndIf
EndIf
EndIf
Sleep(GUICtrlRead($clickDelay));sleep click delay
GuiCtrlSetBkColor($labelStack[$hilfeRepeat], 0xFFFFFF)
_GUICtrlListView_Scroll($idListview, 0, 20)
$hilfeRepeat = $hilfeRepeat + 1
WEnd
$von = $von +1
$hilfeRepeat = 0
Sleep(GUICtrlRead($repeatDelay));sleep stack delay
WEnd
GUICtrlSetBkColor($s3, 0xFFFFFF)
if $enableChecker then
GuiCtrlSetState($checker, $GUI_ENABLE)
EndIf
SetStatus("Done!")
EndFunc