forked from joyrider3774/PinballFXLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLaunchPinballFX.ahk
698 lines (563 loc) · 15.3 KB
/
LaunchPinballFX.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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
; Created by joyrider 3774 05/11/2022
;--------Run Before (Need to be compiled)----Start------
#SingleInstance force
#include Eval.ahk
SetTitleMatchMode, 1
DetectHiddenWindows, On
DetectHiddenText, On
SetWorkingDir %A_ScriptDir%
;------------- User inputs ----------------------
; before activating the window of pinball FX, if it's found. You can increase this if the windows takes longer to show but you might need to lower next value then
WaitBeforeActivate := 6000
; after finding window and waiting to see "press any key to continue"
WaitBeforeGameLoad := 18000
; after game "press any key to continue" screen and waiting before menu is visible
WaitBeforeMenu := 18000
;time between key down / up presses
KeyDelay := 50
;set this to true to let the script enable cabinet mode in the game. You need to set it up before hand correctly
DoCabinetMode := false
;set this to true for testing out the script on your system to know if it's working correctly.
;you should hear 1 beep when the game window is detected then a "WaitBeforeGameLoad" time is slept,
;then you should hear another beep, but this beep should be heared while the press any key to continue message is already displayed
;then "WaitBeforeMenu" ms is slept and you should hear a final beep, this beep should be heared with the menu fully loaded and sitting at
;the news page. If you don't let the game load the news page by default, change it to let it load the news page 1st again or it won't working
;then the script starts selecting the tables
DoPlayBeeps := true
;i noticed my game could loose focuse so if you have problems with that please set doActivateWindow to true
;or if you have problems with the game not receiving input set doActivateWindow to true
;also try out setting the flag to run this script as administrator in properties of your build exe or lower "WaitBeforeActivate" time
DoActivateWindow := true
;-------- constants ----------
GrpZen := 4
GrpBraceYourself := 5
GrpDreamWorks := 6
GrpGearBox := 7
GrpHasBro := 8
GrpLegendary := 9
GrpMarvel := 10
GrpParamount := 11
GrpPeanuts := 12
GrpStarWars := 13
GrpUniversal := 14
GrpWilliams := 15
GrpNickelodeon := 16
;1st element (group) how many times to press down to select group
;2nd element how many times to press down to select row table is on
;3rd element how many times to press right to select table
;--------------- Zen Originals ------------------
TblSorcerersLair := [GrpZen,0,0]
TblWildWest := [GrpZen,0,1]
TblCurseOfTheMummy := [GrpZen,0,2]
TblWrathOfTheElderGods := [GrpZen,0,3]
TblGrimTales := [GrpZen,0,4]
TblSkyPirates := [GrpZen,1,0]
TblPinballNoir := [GrpZen,1,1]
TblCastleStorm := [GrpZen,1,2]
TblAdventureLand := [GrpZen,1,3]
TblSonOfZeus := [GrpZen,1,4]
TblSecretsOfTheDeep := [GrpZen,2,0]
TblRome := [GrpZen,2,1]
TblPasha := [GrpZen,2,2]
TblBioLab := [GrpZen,2,3]
;--------------- BaceYourself ------------------
TblCryptOfTheNecroDancer := [GrpBraceYourself,0,0]
;--------------- DreamWorks ------------------
TblDragonsPinball := [GrpDreamWorks,0,0]
TblTrollsPinball := [GrpDreamWorks,0,1]
TblKungFuPandaPinball := [GrpDreamWorks,0,2]
;--------------- Gearbox ------------------
TblBrotherInArms := [GrpGearBox,0,0]
TblHomeWorld := [GrpGearBox,0,1]
TblBorderlands := [GrpGearBox,0,2]
;--------------- Hasbro ------------------
TblMyLittlePony := [GrpHasBro,0,0]
;--------------- Legendary ------------------
TblGodzilla := [GrpLegendary,0,0]
TblKong := [GrpLegendary,0,1]
TblGodzillaVsKong := [GrpLegendary,0,2]
;--------------- Marvel ------------------
TblMVDeadPool := [GrpMarvel,0,0]
TblMVSpiderMan := [GrpMarvel,0,1]
TblMVBlade := [GrpMarvel,0,2]
TblMVFantasticFour := [GrpMarvel,0,3]
TblMVDrStrange := [GrpMarvel,0,4]
TblMVGhostRider := [GrpMarvel,1,0]
TblMVCaptainAmerica := [GrpMarvel,1,1]
TblMVAvengers := [GrpMarvel,1,2]
TblMVMoonKnight := [GrpMarvel,1,3]
TblMVFearItself := [GrpMarvel,1,4]
TblMVCivilWar := [GrpMarvel,2,0]
TblMVWomenOfPowerChampions := [GrpMarvel,2,1]
TblMVWolverine := [GrpMarvel,2,2]
TblMVWomenOfPowerAForce := [GrpMarvel,2,3]
TblMVAntman := [GrpMarvel,2,4]
TblMVAvengersAgeOfUltron := [GrpMarvel,3,0]
TblMVVenom := [GrpMarvel,3,1]
TblMVIronMan := [GrpMarvel,3,2]
TblMVGuardiansOfTheGalaxy := [GrpMarvel,3,3]
TblMVInfinityGauntlet := [GrpMarvel,3,4]
TblMVXMen := [GrpMarvel,4,0]
TblMVWorldWarHulk := [GrpMarvel,4,1]
TblMVThor := [GrpMarvel,4,2]
;--------------- Paramount ------------------
TblWorldWarZ := [GrpParamount,0,0]
;--------------- Peanuts ------------------
TblSnoopyPinball := [GrpPeanuts,0,0]
;--------------- Star Wars ------------------
TblSWStarfighterAssault := [GrpStarWars,0,0]
TblSWBobaFett := [GrpStarWars,0,1]
TblSWReturnOfTheJedi := [GrpStarWars,0,2]
TblSWDarthVader := [GrpStarWars,0,3]
TblSWHanSolo := [GrpStarWars,0,4]
TblSWCloneWars := [GrpStarWars,1,0]
TblSWNewHope := [GrpStarWars,1,1]
TblSWMastersOfTheForce := [GrpStarWars,1,2]
TblSWMandalorian := [GrpStarWars,1,3]
TblSWClassicCollectibles := [GrpStarWars,1,4]
TblSWDroids := [GrpStarWars,2,0]
TblSWSolo := [GrpStarWars,2,1]
TblSWRebels := [GrpStarWars,2,2]
TblSWBattleOfMimban := [GrpStarWars,2,3]
TblSWCalrissianChronicles := [GrpStarWars,2,4]
TblSWAhchToIsland := [GrpStarWars,3,0]
TblSWRogueOne := [GrpStarWars,3,1]
TblSWTheLastJedi := [GrpStarWars,3,2]
TblSWEmpireStrikesBack := [GrpStarWars,3,3]
TblSWMightOfTheFirstOrder := [GrpStarWars,3,4]
TblSWForceAwakens := [GrpStarWars,4,0]
;--------------- Paramount ------------------
TblBackToTheFuture := [GrpUniversal,0,0]
TblJaws := [GrpUniversal,0,1]
TblET := [GrpUniversal,0,2]
TblJurassicWorld := [GrpUniversal,0,3]
TblJurassicParkPinball := [GrpUniversal,0,4]
TblJurassicParkPinballMayhem := [GrpUniversal,1,0]
;--------------- Williams ------------------
TblTwilightZone := [GrpWilliams,0,0]
TblFishTales := [GrpWilliams,0,1]
TblJunkYard := [GrpWilliams,0,2]
TblAttackFromMars := [GrpWilliams,0,3]
TblPartyZone := [GrpWilliams,0,4]
TblTheGetAway := [GrpWilliams,1,0]
TblMedievalMadness := [GrpWilliams,1,1]
TblBlackRose := [GrpWilliams,1,2]
TblIndianaJones := [GrpWilliams,1,3]
TblTheMachineBrideOfPinBot := [GrpWilliams,1,4]
TblWorldCupSoccer := [GrpWilliams,2,0]
TblMonsterBash := [GrpWilliams,2,1]
TblCreatureOfTheBlackLagoon := [GrpWilliams,2,2]
TblTheAddamsFamily := [GrpWilliams,2,3]
TblChampionPub := [GrpWilliams,2,4]
TblDrDude := [GrpWilliams,3,0]
TblWhiteWater := [GrpWilliams,3,1]
TblSwordsOfFury := [GrpWilliams,3,2]
TblRoadShow := [GrpWilliams,3,3]
TblHurricane := [GrpWilliams,3,4]
TblFunHouse := [GrpWilliams,4,0]
TblSafeCracker := [GrpWilliams,4,1]
TblSpaceStation := [GrpWilliams,4,2]
TblNoGoodGofers := [GrpWilliams,4,3]
TblArabianNights := [GrpWilliams,4,4]
TblTheatreOfMagic := [GrpWilliams,5,0]
TblCirqusVoltaire := [GrpWilliams,5,1]
;--------------- Nickelodeon ------------------
TblGarfieldPinball := [GrpNickelodeon,0,0]
;-------- Aliases as per zen's naming -----------
Table_1 := TblMVCivilWar
Table_2 := TblSWMastersOfTheForce
Table_5 := TblMVFearItself
Table_6 := TblSWStarfighterAssault
Table_7 := TblMVThor
Table_10 := TblSWHanSolo
Table_12 := TblSWNewHope
Table_17 := TblMVAvengers
Table_21 := TblMVGhostRider
Table_22 := TblMVDeadPool
Table_23 := TblPasha
Table_24 := TblSWReturnOfTheJedi
Table_27 := TblBioLab
Table_28 := TblSWDarthVader
Table_29 := TblAdventureLand
Table_30 := TblDrStrange
Table_31 := TblRome
Table_33 := TblSorcerersLair
Table_38 := TblFantasticFour
Table_40 := TblCastleStorm
Table_43 := TblSWEmpireStrikesBack
Table_45 := TblMVBlade
Table_46 := TblMVSpiderMan
Table_47 := TblSWCloneWars
Table_48 := TblMVCaptainAmerica
Table_49 := TblMVMoonKnight
Table_50 := TblMVGuardiansOfTheGalaxy
Table_53 := TblSWBobaFett
Table_56 := TblMVWorldWarHulk
Table_58 := TblSWDroids
Table_59 := TblXMen
Table_60 := TblMVInfinityGauntlet
Table_65 := TblMVIronMan
Table_66 := TblSecretsOfTheDeep
Table_71 := TblMVWolverine
Table_73 := TblMVVenom
Table_75 := TblWildWest
Table_77 := TblSWRebels
Table_78 := TblMVAvengersAgeOfUltron
Table_79 := TblMVAntman
Table_80 := TblSonOfZeus
Table_88 := TblSWForceAwakens
Table_89 := TblSWMightOfTheFirstOrder
Table_93 := TblMVWomenOfPowerAForce
Table_94 := TblMVWomenOfPowerChampions
Table_95 := TblJaws
Table_96 := TblET
Table_97 := TblBackToTheFuture
Table_98 := TblSWRogueOne
Table_100 := TblJurassicParkPinball
Table_101 := TblJurassicWorld
Table_102 := TblJurassicParkPinballMayhem
Table_103 := TblSWTheLastJedi
Table_104 := TblSWAhchToIsland
Table_105 := TblSWSolo
Table_106 := TblSWCalrissianChronicles
Table_107 := TblSWBattleOfMimban
Table_108 := TblFishTales
Table_109 := TblMedievalMadness
Table_110 := TblJunkYard
Table_111 := TblTheGetAway
Table_112 := TblCurseOfTheMummy
Table_113 := TblSkyPirates
Table_117 := TblTheatreOfMagic
Table_118 := TblBlackRose
Table_119 := TblAttackFromMars
Table_120 := TblPartyZone
Table_121 := TblChampionPub
Table_122 := TblSafeCracker
Table_123 := TblPinballNoir
Table_124 := TblWhiteWater
Table_125 := TblRoadShow
Table_126 := TblHurricane
Table_127 := TblCirqusVoltaire
Table_128 := TblNoGoodGofers
Table_129 := TblSpaceStation
Table_130 := TblMonsterBash
Table_131 := TblCreatureOfTheBlackLagoon
Table_132 := TblArabianNights
Table_133 := TblIndianaJones
Table_134 := TblFunHouse
Table_135 := TblDrDude
Table_136 := TblSWMandalorian
Table_137 := TblSWClassicCollectibles
Table_138 := TblMyLittlePony
Table_139 := TblKungFuPandaPinball
Table_140 := TblTrollsPinball
Table_141 := TblDragonsPinball
Table_145 := TblGarfieldPinball
Table_146 := TblSnoopyPinball
Table_147 := TblWrathOfTheElderGods
Table_148 := TblTheMachineBrideOfPinBot
Table_149 := TblSwordsOfFury
Table_150 := TblHomeWorld
Table_151 := TblBrotherInArms
Table_152 := TblBorderlands
Table_153 := TblKong
Table_154 := TblWorldWarZ
Table_155 := TblGrimTales
Table_156 := TblTheAddamsFamily
Table_157 := TblWorldCupSoccer
Table_158 := TblGodzilla
Table_160 := TblGodzillaVsKong
Table_161 := TblCryptOfTheNecroDancer
Table_162 := TblTwilightZone
;--------Run Before (Need to be compiled)----End------
tblname := ""
tblmode := ""
IsSteam := false
Steam := A_Args[1]
if (Steam = "Steam")
{
IsSteam := true
}
if(IsSteam)
{
tblname := A_Args[2]
tblmode := A_Args[3]
}
else
{
tblname := A_Args[1]
tblmode := A_Args[2]
}
tbl := Eval(tblname)[1]
if (tblmode = "")
tblmode := "Classic"
if ((tblmode = "Pro") and !(tbl[1] = GrpWilliams))
tblmode := "Classic"
if(IsSteam)
{
RegRead, SteamDirPath, HKCU, Software\Valve\Steam, SteamPath
Run, "%SteamDirPath%\Steam.exe" -applaunch 2328760
}
else
{
Run, "com.epicgames.launcher://apps/56a31432931740cdb0112d237d7d65aa?action=launch&silent=true"
}
WinWait, PinballFX ahk_class UnrealWindow,, 120000
if (ErrorLevel)
{
MsgBox, WinWait timed out.
exitapp
}
Sleep, WaitBeforeActivate
if (DoActivateWindow)
{
WinActivate, PinballFX ahk_class UnrealWindow
Sleep, 50
}
if (DoPlayBeeps)
{
SoundBeep, 500, 500
}
EnableCabinetMode() {
ControlSend ,, {ESC}, PinballFX ahk_class UnrealWindow
Sleep, 1000
Send {Down down}
Sleep, %KeyDelay%
Send {Down up}
Sleep, %KeyDelay%
Sleep, 250
Send {Enter down}
Sleep, %KeyDelay%
Send {Enter up}
Sleep, %KeyDelay%
Sleep, 500
Send {Enter down}
Sleep, %KeyDelay%
Send {Enter up}
Sleep, %KeyDelay%
Sleep, 500
Send {Up down}
Sleep, %KeyDelay%
Send {Up up}
Sleep, %KeyDelay%
Sleep, 500
Send {Enter down}
Sleep, %KeyDelay%
Send {Enter up}
Sleep, %KeyDelay%
Sleep, 500
ControlSend ,, {ESC}, PinballFX ahk_class UnrealWindow
Sleep, 250
ControlSend ,, {ESC}, PinballFX ahk_class UnrealWindow
}
GotoMenu() {
global KeyDelay
global WaitBeforeGameLoad
global WaitBeforeMenu
global DoPlayBeeps
global DoActivateWindow
Sleep, %WaitBeforeGameLoad%
if (DoPlayBeeps)
{
SoundBeep, 500, 500
}
if (DoActivateWindow)
{
WinActivate, PinballFX ahk_class UnrealWindow
Sleep, 50
}
Send {Enter down}
Sleep, %KeyDelay%
Send {Enter up}
Sleep, %KeyDelay%
Sleep, %WaitBeforeMenu%
if (DoPlayBeeps)
{
SoundBeep, 500, 500
}
Return
}
SelectGameMode(Tbl, GameMode) {
global GrpWilliams
global KeyDelay
NumDownAdd := 0
NumDown := 0
NumRight := 0
if (GameMode = "Pro") {
NumDown := 0
}
if (GameMode = "Arcade") {
NumDown := 1
}
if ((GameMode = "Hotseat2") or (GameMode = "Hotseat3") or (GameMode = "Hotseat4")) {
NumDown := 2
}
if (GameMode = "Practice") {
NumDown := 3
}
if (GameMode = "Flips") {
NumDown := 0
NumRight := 1
}
if (GameMode = "1Ball") {
NumDown := 1
NumRight := 1
}
if (GameMode = "Time") {
NumDown := 2
NumRight := 1
}
if (GameMode = "Distance") {
NumDown := 3
NumRight := 1
}
;with williams table it shifts with one extra down after "Classic" mode because of the added "Pro" Mode
if ((Tbl[1] = GrpWilliams) and !(GameMode = "Classic") and (NumRight = 0)) {
NumDown := NumDown + 1
}
;Select The Mode by pressing Right first
Loop, %NumRight%
{
Send {Right down}
Sleep, %KeyDelay%
Send {Right up}
Sleep, %KeyDelay%
Sleep, 100
}
;Select The Mode by pressing down
Loop, %NumDown%
{
Send {Down down}
Sleep, %KeyDelay%
Send {Down up}
Sleep, %KeyDelay%
Sleep, 100
}
;in case of hotseat 3 player or 4 player still need to select that
if ((GameMode = "Hotseat3") or (GameMode = "Hotseat4")) {
Send {Space down}
Sleep, %KeyDelay%
Send {Space up}
Sleep, %KeyDelay%
Sleep, 100
if (GameMode = "Hotseat3") {
NumRight := 1
}
if (GameMode = "Hotseat4") {
NumRight := 2
}
Loop, %NumRight%
{
Send {Right down}
Sleep, %KeyDelay%
Send {Right up}
Sleep, %KeyDelay%
Sleep, 100
}
Sleep, 100
}
}
;Send Enter + assumes correct position
StartGame() {
global KeyDelay
Send {Enter down}
Sleep, %KeyDelay%
Send {Enter up}
Sleep, %KeyDelay%
Return
}
;need to be on NEWS !!!
SelectTable(Table) {
global KeyDelay
global DoActivateWindow
if (DoActivateWindow)
{
WinActivate, PinballFX ahk_class UnrealWindow
Sleep, 50
}
Send {RShift down}
Sleep, %KeyDelay%
Send {RShift up}
Sleep, %KeyDelay%
Sleep, 1250
ControlSend ,, {ESC}, PinballFX ahk_class UnrealWindow
Sleep, 750
LoopGroupCount := (Table[1])
Loop, %LoopGroupCount%
{
Send {Down down}
Sleep, %KeyDelay%
Send {Down up}
Sleep, %KeyDelay%
Sleep, 250
}
;need to send one return to select the group
Send {Return down}
Sleep, %KeyDelay%
Send {Return up}
Sleep, %KeyDelay%
Sleep, 250
;need to press Esc Again to close group selection and be on table selection
ControlSend ,, {ESC}, PinballFX ahk_class UnrealWindow
Sleep, 750
LoopRowCount := (Table[2])
Loop, %LoopRowCount%
{
Send {Down down}
Sleep, %KeyDelay%
Send {Down up}
Sleep, %KeyDelay%
Sleep, 50
}
LoopColCount := (Table[3])
Loop, %LoopColCount%
{
Send {Right down}
Sleep, %KeyDelay%
Send {Right up}
Sleep, %KeyDelay%
Sleep, 50
}
Sleep, 250
;select the table
Send {Enter down}
Sleep, %KeyDelay%
Send {Enter up}
Sleep, %KeyDelay%
Sleep, 750
;press play on table
Send {Enter down}
Sleep, %KeyDelay%
Send {Enter up}
Sleep, %KeyDelay%
Sleep, 750
Return
}
GotoMenu()
if (DoCabinetMode)
{
EnableCabinetMode()
}
SelectTable(tbl)
SelectGameMode(tbl, tblmode)
StartGame()
Process, WaitClose, PinballFX-Win64-Shipping.exe
ExitApp
;--------Run After (Need to be compiled)----End------
#IfWinActive PinballFX ahk_class UnrealWindow
; Exit Table
; ~Esc::
; Gosub killApp
; Sleep, 750
; Send {Esc}
; Return
#IfWinActive
killApp:
Send !{f4}
Process, Close, PinballFX-Win64-Shipping.exe
If ErrorLevel
Process, Close, %ErrorLevel%
WinKill, Error
WinKill, PinballFX ahk_class UnrealWindow
Run, taskkill /F /IM PinballFX-Win64-Shipping.exe /T,, Hide
Return