-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathPTCGPB.ahk
476 lines (393 loc) · 16.6 KB
/
PTCGPB.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
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
version = Arturos PTCGP Bot
#SingleInstance, force
CoordMode, Mouse, Screen
SetTitleMatchMode, 3
global Instances, jsonFileName, PacksText
totalFile := A_ScriptDir . "\json\total.json"
backupFile := A_ScriptDir . "\json\total-backup.json"
if FileExist(totalFile) ; Check if the file exists
{
FileCopy, %totalFile%, %backupFile%, 1 ; Copy source file to target
if (ErrorLevel)
MsgBox, Failed to create %backupFile%. Ensure permissions and paths are correct.
}
FileDelete, %totalFile%
packsFile := A_ScriptDir . "\json\Packs.json"
backupFile := A_ScriptDir . "\json\Packs-backup.json"
if FileExist(packsFile) ; Check if the file exists
{
FileCopy, %packsFile%, %backupFile%, 1 ; Copy source file to target
if (ErrorLevel)
MsgBox, Failed to create %backupFile%. Ensure permissions and paths are correct.
}
InitializeJsonFile() ; Create or open the JSON file
; Create the main GUI for selecting number of instances
IniRead, EnteredName, Settings.ini, UserSettings, EnteredName
IniRead, Delay, Settings.ini, UserSettings, Delay, 250
IniRead, folderPath, Settings.ini, UserSettings, folderPath, C:\Program Files\Netease
IniRead, discordWebhookURL, Settings.ini, UserSettings, discordWebhookURL, ""
IniRead, discordUserId, Settings.ini, UserSettings, discordUserId, ""
IniRead, changeDate, Settings.ini, UserSettings, ChangeDate, 0100
IniRead, Columns, Settings.ini, UserSettings, Columns, 5
IniRead, openPack, Settings.ini, UserSettings, openPack, Mew
IniRead, godPack, Settings.ini, UserSettings, godPack, Continue
IniRead, Instances, Settings.ini, UserSettings, Instances, 1
IniRead, setSpeed, Settings.ini, UserSettings, setSpeed, 2x
IniRead, defaultLanguage, Settings.ini, UserSettings, defaultLanguage, Scale125
IniRead, SelectedMonitorIndex, Settings.ini, UserSettings, SelectedMonitorIndex, 1
IniRead, swipeSpeed, Settings.ini, UserSettings, swipeSpeed, 600
IniRead, skipInvalidGP, Settings.ini, UserSettings, skipInvalidGP, Yes
IniRead, deleteMethod, Settings.ini, UserSettings, deleteMethod, Clicks
; Main GUI setup
; Add the link text at the bottom of the GUI
Gui, Show, w500 h640, Arturo's PTCGPB Bot Setup ;' Ensure the GUI size is appropriate
Gui, Color, White ; Set the background color to white
Gui, Font, s10 Bold , Segoe UI
; Add the button image on top of the GUI
;Gui, Add, Picture, gStart x196 y196 w108 h108 vImageButton +BackgroundTrans, %normalImage%
Gui, Add, Button, gArrangeWindows x215 y208 w70 h32, Arrange Windows
Gui, Add, Button, gStart x227 y258 w46 h32 vArrangeWindows, Start
Gui, Add, Text, x0 y604 w640 h30 vLinkText gOpenLink cBlue Center +BackgroundTrans
Gui, Font, s15 Bold , Segoe UI
; Add the background image to the GUI
Gui, Add, Picture, x0 y0 w500 h640, %A_ScriptDir%\Scripts\GUI\GUI.png
; Add input controls
if(EnteredName = "ERROR")
EnteredName =
if(EnteredName = )
Gui, Add, Edit, vEnteredName x80 y95 w145 Center
else
Gui, Add, Edit, vEnteredName x80 y95 w145 Center, %EnteredName%
Gui, Add, Edit, vInstances x275 y95 w72 Center, %Instances%
Gui, Add, Edit, vColumns x348 y95 w72 Center, %Columns%
; Pack selection logic
if (openPack = "Mewtwo") {
defaultPack := 1
} else if (openPack = "Pikachu") {
defaultPack := 2
} else if (openPack = "Charizard") {
defaultPack := 3
} else if (openPack = "Mew") {
defaultPack := 4
} else if (openPack = "Random") {
defaultPack := 5
}
Gui, Add, DropDownList, x80 y166 w145 vopenPack choose%defaultPack% Center, Mewtwo|Pikachu|Charizard|Mew|Random
global scaleParam
if (defaultLanguage = "Scale125") {
defaultLang := 1
scaleParam := 277
} else if (defaultLanguage = "Scale100") {
defaultLang := 2
scaleParam := 287
}
Gui, Add, DropDownList, x80 y245 w145 vdefaultLanguage choose%defaultLang%, Scale125|Scale100
; Initialize monitor dropdown options
SysGet, MonitorCount, MonitorCount
MonitorOptions := ""
Loop, %MonitorCount%
{
SysGet, MonitorName, MonitorName, %A_Index%
SysGet, Monitor, Monitor, %A_Index%
MonitorOptions .= (A_Index > 1 ? "|" : "") "" A_Index ": (" MonitorRight - MonitorLeft "x" MonitorBottom - MonitorTop ")"
}
SelectedMonitorIndex := RegExReplace(SelectedMonitorIndex, ":.*$")
Gui, Add, DropDownList, x275 y245 w145 vSelectedMonitorIndex Choose%SelectedMonitorIndex%, %MonitorOptions%
Gui, Add, Edit, vDelay x80 y332 w145 Center, %Delay%
Gui, Add, Edit, vChangeDate x275 y332 w145 Center, %ChangeDate%
; Speed selection logic
if (setSpeed = "2x") {
defaultSpeed := 1
} else if (setSpeed = "1x/2x") {
defaultSpeed := 2
} else if (setSpeed = "1x/3x") {
defaultSpeed := 3
}
Gui, Add, DropDownList, x275 y404 w72 vsetSpeed choose%defaultSpeed% Center, 2x|1x/2x|1x/3x
Gui, Add, Edit, vswipeSpeed x348 y404 w72 Center, %swipeSpeed%
; Pack selection logic
if (godPack = "Close") {
defaultgodPack := 1
} else if (godPack = "Pause") {
defaultgodPack := 2
} else if (godPack = "Continue") {
defaultgodPack := 3
}
Gui, Add, DropDownList, x275 y166 w145 vgodPack choose%defaultgodPack% Center, Close|Pause|Continue
; Pack selection logic
if (skipInvalidGP = "No") {
defaultskipGP := 1
} else if (skipInvalidGP = "Yes") {
defaultskipGP := 2
}
Gui, Add, DropDownList, x80 y476 w145 vskipInvalidGP choose%defaultskipGP% Center, No|Yes
; Pack selection logic
if (deleteMethod = "File") {
defaultDelete := 1
} else if (deleteMethod = "Clicks") {
defaultDelete := 2
}
Gui, Add, DropDownList, x80 y546 w145 vdeleteMethod choose%defaultDelete% Center, File|Clicks
Gui, Font, s10 Bold, Segoe UI
Gui, Add, Edit, vfolderPath x80 y404 w145 h35 Center, %folderPath%
if(StrLen(discordUserID) > 2)
Gui, Add, Edit, vdiscordUserId x273 y476 w72 h35 Center, %discordUserId%
else
Gui, Add, Edit, vdiscordUserId x273 y476 w72 h35 Center
if(StrLen(discordWebhookURL) > 2)
Gui, Add, Edit, vdiscordWebhookURL x348 y476 w72 h35 Center, %discordWebhookURL%
else
Gui, Add, Edit, vdiscordWebhookURL x348 y476 w72 h35 Center
Gui, Font, s10 cGray Norm Bold, Segoe UI ; Normal font for input labels
Gui Add, Button, x190 y72 w17 h19 gShowMsgName, ? ;Questionmark box for Name Field
Gui Add, Button, x342 y77 w17 h19 gShowMsgInstances, ? ;Questionmark box for Instance Field
Gui Add, Button, x415 y77 w17 h19 gShowMsgColumns, ? ;Questionmark box for Instance Per Row Field
Gui Add, Button, x190 y145 w17 h19 gShowMsgPacks, ? ;Questionmark box for Pack to Open Field
Gui Add, Button, x423 y145 w17 h19 gShowMsgGodPacks, ? ;Questionmark box for God Pack to Open Field
Gui Add, Button, x78 y219 w17 h19 gShowMsgLanguage, ? ;Questionmark box for God Pack to Open Field
Gui Add, Button, x400 y219 w17 h19 gShowMsgMonitor, ? ;Questionmark box for God Pack to Open Field
Gui Add, Button, x192 y307 w17 h19 gShowMsgDelay, ? ;Questionmark box for Delay in ms Field
Gui Add, Button, x411 y307 w17 h19 gShowMsgTimeZone, ? ;Questionmark box for Timezone Field
Gui Add, Button, x193 y378 w17 h19 gShowMsgFolder, ? ;Questionmark box for SwipeSpeed Field
Gui Add, Button, x343 y378 w17 h19 gShowMsgSpeed, ? ;Questionmark box for Speed Field
Gui Add, Button, x408 y378 w17 h19 gShowMsgSwipeSpeed, ? ;Questionmark box for SwipeSpeed Field
Gui Add, Button, x428 y448 w17 h19 gShowMsgdiscordwebHook, ? ;Questionmark box for discord id Field
Gui Add, Button, x330 y448 w17 h19 gShowMsgdiscordID, ? ;Questionmark box for discord web hook Field
Gui Add, Button, x230 y518 w17 h19 gShowMsgAccountDeletion, ? ;Questionmark box for Account Deletion to Open Field
Gui Add, Button, x235 y448 w17 h19 gShowMsgSkipGP, ? ;Questionmark box for Account Deletion to Open Field
; Show the GUI
Gui, Show
return
ShowMsgName:
MsgBox, Input the name you want the accounts to have. `nIf it's getting stuck inputting the name then make sure your dpi is set to 220.`nLeave blank for a random pokemon name ;'
return
ShowMsgInstances:
MsgBox, Input how many instances you are running
return
ShowMsgColumns:
MsgBox, Input the number of instances per row
return
ShowMsgPacks:
MsgBox, Select the pack you want to open
return
ShowMsgGodPacks:
MsgBox, Select the behavior you want when finding a god pack. `nClose will close the emulator and stop the script to save resources. `nPause will only pause the script on the opening screen. `nContinue will save the account data to a file and continue rolling with the instance. The xml account data can then be injected into an instance using the tools in the 'Accounts' folder to recover the god pack.
return
ShowMsgLanguage:
MsgBox, Select your game's language. In order to change your language > change language settings in mumu > delete the game account data. ;'
return
ShowMsgMonitor:
MsgBox, Select the monitor you want the instances to be on. `nBe sure to start them on that monitor to prevent issues. `nIf you're having issues make sure all monitors are set to 125`% scale or the scale you have chosen ;'
return
ShowMsgDelay:
MsgBox, Input the delay in between clicks.
return
ShowMsgTimeZone:
MsgBox, What time the date change is for you. `n1 AM EST is default you can look up what that is in your time zone.
return
ShowMsgFolder:
MsgBox, Where the "MuMuPlayerGlobal-12.0" folder is located. `nTypically it's in the Netease folder: C:\Program Files\Netease ;'
return
ShowMsgSpeed:
MsgBox, Select the speed configuration. `n2x flat speed. (usually better when maxing out your system) `n1x/2x to swipe at 1x speed then do the rest on 2x. This needs the new speed mod in the guide. (Good option if you are having issues swiping on flat 2x speed) `n1x/3x to swipe at 1x speed then do the reset on 3x. This needs the new speed mod in the guide. (usually better when running fewer instances)
return
ShowMsgSwipeSpeed:
MsgBox, Input the swipe speed in milliseconds. `nAnything from 100 to 1000 can probably work. `nPlay around with the speed to get the best speed for your system. Lower number = faster speed.
return
ShowMsgdiscordID:
MsgBox, Input your discord ID for pings using webhook. Not your username, but your numerical discord ID.
return
ShowMsgdiscordwebHook:
MsgBox, Input your server's webhook. It will be something like: https://discord.com/api/webhooks/124124151245/oihri1u24hifb12oiu43hy1 `nCreate a server in discord > for any channel > click the edit channel cog wheel > integrations > create a webhook > click on the webhook created > copy webhook url. Paste that here. ;'
return
ShowMsgAccountDeletion:
MsgBox, Select the method to delete the account. `nFile method deletes the XML file and then closes/reopens the game. This should be more efficient. `nClicks method will simulate clicking and deleting the account through the Menu. Use this if for some reason your game takes a long time starting up.
return
ShowMsgSkipGP:
MsgBox, Select whether or not to skip god packs. If you skip them you will still receive a discord ping and the account XML is also saved in the Accounts folder.
return
ArrangeWindows:
GuiControlGet, Instances,, Instances
GuiControlGet, Columns,, Columns
GuiControlGet, SelectedMonitorIndex,, SelectedMonitorIndex
Loop %Instances% {
resetWindows(A_Index, SelectedMonitorIndex)
sleep, 10
}
return
; Handle the link click
OpenLink:
Run, https://buymeacoffee.com/aarturoo
return
Start:
Gui, Submit ; Collect the input values from the first page
Instances := Instances ; Directly reference the "Instances" variable
; Create the second page dynamically based on the number of instances
Gui, Destroy ; Close the first page
IniWrite, %EnteredName%, Settings.ini, UserSettings, EnteredName
IniWrite, %Delay%, Settings.ini, UserSettings, Delay
IniWrite, %folderPath%, Settings.ini, UserSettings, folderPath
IniWrite, %discordWebhookURL%, Settings.ini, UserSettings, discordWebhookURL
IniWrite, %discordUserId%, Settings.ini, UserSettings, discordUserId
IniWrite, %ChangeDate%, Settings.ini, UserSettings, ChangeDate
IniWrite, %Columns%, Settings.ini, UserSettings, Columns
IniWrite, %openPack%, Settings.ini, UserSettings, openPack
IniWrite, %godPack%, Settings.ini, UserSettings, godPack
IniWrite, %Instances%, Settings.ini, UserSettings, Instances
IniWrite, %setSpeed%, Settings.ini, UserSettings, setSpeed
IniWrite, %defaultLanguage%, Settings.ini, UserSettings, defaultLanguage
IniWrite, %SelectedMonitorIndex%, Settings.ini, UserSettings, SelectedMonitorIndex
IniWrite, %swipeSpeed%, Settings.ini, UserSettings, swipeSpeed
IniWrite, %skipInvalidGP%, Settings.ini, UserSettings, skipInvalidGP
IniWrite, %deleteMethod%, Settings.ini, UserSettings, deleteMethod
; Loop to process each instance
Loop, %Instances%
{
SourceFile := "Scripts\1.ahk" ; Path to the source .ahk file
TargetFolder := "Scripts\" ; Path to the target folder
TargetFile := TargetFolder . "\" . A_Index . ".ahk" ; Generate target file path
if !FileExist(TargetFile) ; Check if the file doesn't exist
{
FileCopy, %SourceFile%, %TargetFile%, 1 ; Copy source file to target
if (ErrorLevel)
MsgBox, Failed to create %TargetFile%. Ensure permissions and paths are correct.
}
FileName := "Scripts\"A_Index ".ahk"
Command := FileName
Run, %Command%
}
SelectedMonitorIndex := RegExReplace(SelectedMonitorIndex, ":.*$")
SysGet, Monitor, Monitor, %SelectedMonitorIndex%
rerollTime := A_TickCount
Loop {
; Sum all variable values and write to total.json
total := SumVariablesInJsonFile()
totalSeconds := Round((A_TickCount - rerollTime) / 1000) ; Total time in seconds
mminutes := Floor(totalSeconds / 60)
if(total = 0)
total := "0 "
CreateStatusMessage("Time: " . mminutes . "m Packs: " . total, 5, 490)
Sleep, 10000
}
Return
GuiClose:
ExitApp
resetWindows(Title, SelectedMonitorIndex){
global Columns
RetryCount := 0
MaxRetries := 10
Loop
{
try {
; Get monitor origin from index
SelectedMonitorIndex := RegExReplace(SelectedMonitorIndex, ":.*$")
SysGet, Monitor, Monitor, %SelectedMonitorIndex%
rowHeight := 533 ; Adjust the height of each row
currentRow := Floor((Title - 1) / Columns)
y := currentRow * rowHeight
x := Mod((Title - 1), Columns) * scaleParam
WinMove, %Title%, , % (MonitorLeft + x), % (MonitorTop + y), scaleParam, 537
break
}
catch {
if (RetryCount > MaxRetries)
Pause
}
Sleep, 1000
}
return true
}
CreateStatusMessage(Message, X := 0, Y := 80) {
global PacksText, SelectedMonitorIndex, createdGUI, Instances
MaxRetries := 10
RetryCount := 0
try {
GuiName := 22
SelectedMonitorIndex := RegExReplace(SelectedMonitorIndex, ":.*$")
SysGet, Monitor, Monitor, %SelectedMonitorIndex%
X := MonitorLeft + X
Y := MonitorTop + Y
Gui %GuiName%:+LastFoundExist
if WinExist() {
GuiControl, , PacksText, %Message%
} else { OwnerWND := WinExist(1)
if(!OwnerWND)
Gui, %GuiName%:New, +ToolWindow -Caption
else
Gui, %GuiName%:New, +Owner%OwnerWND% +ToolWindow -Caption
Gui, %GuiName%:Margin, 2, 2 ; Set margin for the GUI
Gui, %GuiName%:Font, s8 ; Set the font size to 8 (adjust as needed)
Gui, %GuiName%:Add, Text, vPacksText, %Message%
Gui, %GuiName%:Show, NoActivate x%X% y%Y%, NoActivate %GuiName%
}
}
}
; Global variable to track the current JSON file
global jsonFileName := ""
; Function to create or select the JSON file
InitializeJsonFile() {
global jsonFileName
fileName := A_ScriptDir . "\json\Packs.json"
if FileExist(fileName)
FileDelete, %fileName%
if !FileExist(fileName) {
; Create a new file with an empty JSON array
FileAppend, [], %fileName% ; Write an empty JSON array
jsonFileName := fileName
return
}
}
; Function to append a time and variable pair to the JSON file
AppendToJsonFile(variableValue) {
global jsonFileName
if (jsonFileName = "") {
MsgBox, JSON file not initialized. Call InitializeJsonFile() first.
return
}
; Read the current content of the JSON file
FileRead, jsonContent, %jsonFileName%
if (jsonContent = "") {
jsonContent := "[]"
}
; Parse and modify the JSON content
jsonContent := SubStr(jsonContent, 1, StrLen(jsonContent) - 1) ; Remove trailing bracket
if (jsonContent != "[")
jsonContent .= ","
jsonContent .= "{""time"": """ A_Now """, ""variable"": " variableValue "}]"
; Write the updated JSON back to the file
FileDelete, %jsonFileName%
FileAppend, %jsonContent%, %jsonFileName%
}
; Function to sum all variable values in the JSON file
SumVariablesInJsonFile() {
global jsonFileName
if (jsonFileName = "") {
return
}
; Read the file content
FileRead, jsonContent, %jsonFileName%
if (jsonContent = "") {
return 0
}
; Parse the JSON and calculate the sum
sum := 0
; Clean and parse JSON content
jsonContent := StrReplace(jsonContent, "[", "") ; Remove starting bracket
jsonContent := StrReplace(jsonContent, "]", "") ; Remove ending bracket
Loop, Parse, jsonContent, {, }
{
; Match each variable value
if (RegExMatch(A_LoopField, """variable"":\s*(-?\d+)", match)) {
sum += match1
}
}
; Write the total sum to a file called "total.json"
if(sum > 0) {
totalFile := A_ScriptDir . "\json\total.json"
totalContent := "{""total_sum"": " sum "}"
FileDelete, %totalFile%
FileAppend, %totalContent%, %totalFile%
}
return sum
}
~F7::ExitApp