-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAutoCodes.ahk
281 lines (238 loc) · 7.75 KB
/
AutoCodes.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
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
;tbd: try clipboard and warn user if broken,better settings,unlimited amount of selection points,support codes from other games (roblox atleast),add exception to autohotkey's toolitp,support multiple instances (maybe)
#NoEnv
#Persistent
#SingleInstance Force
;#Warn
OnExit,Exit
SetWorkingDir %A_ScriptDir%
CodesList := []
MsgSelect := ["Select the side redeem button. 💳`n(Use Middle 🖱 to select.)","Select the code input box. ⌨`n(Use Middle 🖱 to select.)","Select the redeem button. ✔`n(Use Middle 🖱 to select.)","Select the exit button. ❌`n(Use Middle 🖱 to select.)"]
If FileExist("config.ini"){
IniRead, URL, config.ini, Settings | Data,URL
IniRead, IconDark, config.ini, Settings | Icons, IconDark
IniRead, IconLight, config.ini, Settings | Icons, IconLight
IniRead, IconMulti, config.ini, Settings | Icons, IconMulti
;IniRead, CodesList, config.ini, Settings | Codes, CodesList
;IniRead, MsgSelect, config.ini, Settings | Messages, MsgSelect
IniRead, MouseSpeed, config.ini, Settings | Extra,MouseSpeed
IniRead, SCalibration, config.ini, Settings | Calibration,SCalibration
IniRead, Calibrated, config.ini, Settings | Calibration,Calibrated
IniRead, x1, config.ini, Settings | Calibration,x1
IniRead, x2, config.ini, Settings | Calibration,x2
IniRead, x3, config.ini, Settings | Calibration,x3
IniRead, x4, config.ini, Settings | Calibration,x4
IniRead, KeyDelay, config.ini, Settings | Extra,KeyDelay
IniRead, Selection, config.ini, Settings | Extra, Selection
IniRead, SelectionR, config.ini, Settings | Extra, SelectionR
IniRead, Experimental, config.ini, Settings | Experimental, Experimental
SetDefaultMouseSpeed,%MouseSpeed%
SetKeyDelay,%KeyDelay%
}else{
SetKeyDelay,1,-1
SetDefaultMouseSpeed,4
URL := "https://raw.githubusercontent.com/NotWaveWayz/AutoCodes/main/codes.txt"
IconDark := "Dark.ico"
IconLight := "Light.ico"
IconMulti := "Multi.ico"
Selection := 0
SelectionR := 0
Experimental := False
IniWrite, %URL%, config.ini, Settings | Data,URL
IniWrite, %IconDark%, config.ini, Settings | Icons,IconDark
IniWrite, %IconLight%, config.ini, Settings | Icons,IconLight
IniWrite, %IconMulti%, config.ini, Settings | Icons,IconMulti
;IniWrite, %CodesList%, config.ini, Settings | Codes,CodesList
;IniWrite, %MsgSelect%, config.ini, Settings | Messages,MsgSelect
IniWrite, %A_DefaultMouseSpeed%, config.ini, Settings | Extra,MouseSpeed
IniWrite, %SCalibration%, config.ini, Settings | Calibration,SCalibration
IniWrite, %Calibrated%, config.ini, Settings | Calibration,Calibrated
IniWrite, %x1%, config.ini, Settings | Calibration,x1
IniWrite, %x2%, config.ini, Settings | Calibration,x2
IniWrite, %x3%, config.ini, Settings | Calibration,x3
IniWrite, %x4%, config.ini, Settings | Calibration,x4
IniWrite, %A_KeyDelay%, config.ini, Settings | Extra,KeyDelay
IniWrite, %Selection%, config.ini, Settings | Extra,Selection
IniWrite, %SelectionR%, config.ini, Settings | Extra,SelectionR
IniWrite, %Experimental%, config.ini, Settings | Experimental,Experimental
}
If FileExist(IconMulti)
Menu,Tray,Icon,%IconMulti%,,1
; gui settings ;
Gui,5: -MinimizeBox +AlwaysOnTop
Gui,4: -MinimizeBox +AlwaysOnTop
Gui,3: -MinimizeBox +AlwaysOnTop
Gui,2a: -MinimizeBox +AlwaysOnTop
Gui,2: -MinimizeBox +AlwaysOnTop
; main gui ;
Gui,Add,Button,w300 gContinue,▶ Continue ▶
Gui,Add,Button,w300 gSettings,Settings
Gui, Add, StatusBar,,No information available.
; codes manager ;
Gui,2:Add,Text,,What would you like to do?
Gui,2:Add,Button,w150 vCodesLoad gLoad,⤵ Insert Codes ⤵
Gui,2:Add,Button,w150 gViewT,👁 View Raw Text 👁
Gui,2:Add,Button,w150 gSaveL,💾 Save Locally 💾
; additional guis (mainly single purpose) ;
Gui,2a:Add,Edit,vPromptText ReadOnly w300 h300
; settings ;
Gui,5:Add,Button,w150 gLibrary,Library
Gui,5:Add,Button,w150 vCalibrate gCalibrate,Calibrate
Gui,5:Add,Text,,Methods of sending codes:
Gui,5:Add,Radio, vSEMethod gCodeMethod Checked,SendEvent
Gui,5:Add,Radio,vMCMethod gCodeMethod,MClipboard
Gui,5:Font,s6
Gui,5:Add,Text,w150,Note: MClipboard (Magic Clipboard) temporary replaces saved clipboard data until finished.
Gui,5:Font,s7
; expiremental stuff ;
If (Experimental){
Gui,2:Add,Button,w300,💿 Save As Text 💿
}
Gui,Show,,AutoCodes
; maintaince ;
GoSub,Check
GoSub,UpdateCodes
; gui icon set ;
if (FileExist(IconDark) && FileExist(IconLight)){
RegRead, SystemTheme, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize , SystemUsesLightTheme
Menu,Tray,Icon,% (SystemTheme) ? "Dark.ico" : "Light.ico",,1
}Else If FileExist(IconMulti)
Menu,Tray,Icon,%IconMulti%,,1
Return
CodeMethod:
Return
; save locally ;
SaveL:
FileAppend,- Saved using AutoCodes @ (%A_NowUTC%:UTC) -`n`n%CodesRaw%,AutoCodes%A_NowUTC%.txt
Return
; load codes ;
Load:
CLoading := True
Gui,5:Submit,NoHide
If (MCMethod)
PreClipboard := Clipboard
WinActivate,ahk_exe RobloxPlayerBeta.exe
MouseMove,%xs1%,%ys1%,0
Click,%x1% %y1%
MouseMove,%xs2%,%ys2%,0
Loop % Codes.MaxIndex(){
MouseMove,%xs2%,%ys2%,0
Click,%x2% %y2%
SendInput,^a{BS}
If (MCMethod){
Clipboard := Codes[A_Index]
SendInput,^v
}Else{
Send,% Codes[A_Index]
}
MouseMove,%xs3%,%ys3%,0
Click,%x3% %y3%
MouseMove,%xs2%,%ys2%,0
Click,%x2% %y2%
}
SendInput,^a{BS}
MouseMove,%xs4%,%ys4%,0
Click,%x4% %y4%
If (MCMethod)
Clipboard := PreClipboard
CLoading := False
Return
; > continue > ;
Continue:
Gui,2:Show,,Manager
Return
; view raw text ;
ViewT:
GuiControl,2a:,PromptText,%CodesRaw%
Gui,2a:Show,,Text Viewer
Return
; save as text (ex) ;
SaveT:
doc := ComObjCreate("HTMLFile")
doc.Write(CodesRaw)
ECodes := doc.body.innerText
FileAppend,- Saved using AutoCodes[E] @ (%A_NowUTC%:UTC) -`n`n%ECodes%,AutoCodes%A_NowUTC%.txt
Return
; show settings gui ;
Settings:
Gui,5:Show,,Settings
Return
; middle button calibration ;
~MButton::
If (Calibrating)
GoSub,Calibrate
Return
; calibration ;
Calibrate:
Calibrated := False
Calibrating := True
Selection++
GuiControl,5:Disable,Calibrate
If (Selection < 5){
If (Selection = 1)
ToolTip, % MsgSelect[Selection]
WinGet,CaliCheckWin,ID,ahk_exe RobloxPlayerBeta.exe
MouseGetPos,x%Selection%,y%Selection%,CaliWin
If not (CaliWin = CaliCheckWin){
Selection := SelectionR
Return
}Else{
ToolTip, % MsgSelect[Selection+1]
xs%Selection% := x%Selection% - 1
ys%Selection% := y%Selection% - 1
If (Selection = 1 || Selection = 4)
Click
}If not (Selection < 4){
Loop 500
ToolTip,Successfully Calibrated!
ToolTip
Calibrating := False
Calibrated := True
GuiControl,5:Enable,Calibrate
GoSub,Check
Selection := SelectionR
}
}
Return
; tbd soon (library to select game codes) ;
Library:
Return
; load codes/ update ;
UpdateCodes:
SB_SetText("Loading codes.")
CodesLoading := True
xmlhttp := ComObjCreate("MSXML2.XMLHTTP")
xmlhttp.Open("GET", URL, false)
xmlhttp.Send()
Codes := StrSplit(RTrim(xmlhttp.ResponseText,"`n"),"`n")
CodesRaw := xmlhttp.ResponseText
CodesLoading := False
SB_SetText("Codes Loaded.")
GoSub,Check
Return
; manage stuff ;
Check:
If not (Calibrated){
GuiControl,Disable,▶ Continue ▶
SB_SetText("Mouse positions must be calibrated first.")
}Else If (Calibrated){
GuiControl,Enable,▶ Continue ▶
SB_SetText("Mouse positions successfully calibrated.")
}Else
SB_SetText("No information available.")
Return
; boring exit stuff ;
GuiClose:
ExitApp
Return
Exit:
If (MCMethod && CLoading)
Clipboard := PreClipboard
If (Calibrated && SCalibraiton){
IniWrite, %Calibrated%, config.ini, Settings | Calibration,Calibrated
IniWrite, %x1%, config.ini, Settings | Calibration,x1
IniWrite, %x2%, config.ini, Settings | Calibration,x2
IniWrite, %x3%, config.ini, Settings | Calibration,x3
IniWrite, %x4%, config.ini, Settings | Calibration,x4
}
ExitApp
Return