-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEWZbot_Script.ahk
5667 lines (4817 loc) · 183 KB
/
LEWZbot_Script.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
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; #NoEnv Recommended for performance and compatibility with future AutoHotkey releases, it disables environment variables.
; #Warn ; Enable warnings to assist with detecting common errors.
; default #MaxHotkeysPerInterval along with #HotkeyInterval will stop your script by showing message boxes if you have some kind of rapid autofire loop in it.
; ListLines and #KeyHistory are functions used to "log your keys". Disable them as they're only useful for debugging purposes.
; Setting an higher priority to a Windows program is supposed to improve its performance. Use AboveNormal/A. If you feel like it's making things worse, comment or remove this line.
; The default SetBatchLines value makes your script sleep 10 milliseconds every line. Make it -1 to not sleep (but remember to include at least one Sleep in your loops, if any!)
; Even though SendInput ignores SetKeyDelay, SetMouseDelay and SetDefaultMouseSpeed, having these delays at -1 improves SendEvent's speed just in case SendInput is not available and falls back to SendEvent.
; SetWinDelay and SetControlDelay may affect performance depending on the script.
; SendInput is the fastest send method. SendEvent (the default one) is 2nd place, SendPlay a far 3rd place (it's the most compatible one though). SendInput does not obey to SetKeyDelay, SetMouseDelay, SetDefaultMouseSpeed; there is no delay between keystrokes in that mode.
;OPTIMIZATIONS START
; #NoTrayIcon ; if you don't want a tray icon for this AutoHotkey program.
#SingleInstance force ; Skips the dialog box and replaces the old instance automatically
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; disables environment variables
; #WinActivateForce
#Warn All, Off
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off ; Omits subsequently-executed lines from the history.
; ListLines On ; Includes subsequently-executed lines in the history. This is the starting default for all scripts.
Process, Priority, , H
SetBatchLines, -1
SetKeyDelay, -1 ; , 20 ; -1 ; default
SetMouseDelay, -1 ; -1 ; default
SetDefaultMouseSpeed, 0 ; 3 ; 0 ; Move the mouse SPEED.
SetWinDelay, -1 ; -1 ; default
SetControlDelay, -1 ; -1 ; default ; Sets the delay that will occur after each control-modifying command.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;OPTIMIZATIONS END
EnvGet, USER_PROFILE, USERPROFILE
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; SetWorkingDir, %USER_PROFILE%\Desktop\MEmu
; SetWorkingDir "C:\Users\CowNi\Desktop\MEmu"
#include <Vis2>
#include lib\CowNinja_Functions.ahk
#include lib\LEWZ_SetDefaults.ahk
#Include %A_ScriptDir%\node_modules
#Include graphicsearch.ahk\export.ahk
; #Include %A_ScriptDir%\node_modules\json.ahk\export.ahk
; #Include json.ahk\export.ahk
#Include unit-testing.ahk\export.ahk
; #include lib\WindowListMenu_mod_004.ahk
; #include lib\LEWZ_Functions.ahk
; #include lib\LEWZ_Functions_1057_mod_002.ahk
; #include <Gdip_All>
; #include <SnapOCR>
; ********** Main program begins here **********
; MsgBox, Found: %FoundAppTitle%, Pause (pause/resume) F4 (Exit)
; If WinExist("MEmu") or WinExist("MEmu") or WinExist("MEmu.exe") or WinExist("MEmu.exe")
while WinExist(FoundAppTitle)
{
Elivate_program()
; If WinExist(FoundAppTitle)
main_program:
loop
{
; ([Subroutine_Running,A_ThisLabel,FoundAppTitle,FoundAppClass,FoundAppControl,FoundAppProcess])
; stdout.WriteLine(A_NowUTC ",Main_loop," image_name ",Main_Loop_Counter:," Main_Loop_Counter ",Restart_Loops:," Restart_Loops ",Reset_App_Yes:," Reset_App_Yes)
; if !WinActive(FoundAppTitle), WinActivate, %FoundAppTitle% ; WinActivate ; Automatically uses the window found above.
; MouseMove UpperX+(WinWidth/2), UpperY+(WinHeight/2)
; Generate Random time interval to add to all delays and pauses
Random, rand_wait, %rand_min%, %rand_max%
Key_Menu() ; display/update keyboard shortcut menu
; Process_Menu()
; Switch User
; For User,Val in User_Logins
for User,Val in Base_Array
{
; Get_Window_Geometry()
Check_Window_Geometry()
; WinActivate, %FoundAppTitle% ; Automatically uses the window found above.
; ([FoundAppTitle,FoundAppClass,FoundAppControl,FoundAppProcess])
; Populate account variables from next keyed array item
global User_Name := Base_Array[User].User_Name_new
global User_Email := Base_Array[User].User_Email
global User_Pass := Base_Array[User].User_Pass
global User_PIN := Base_Array[User].User_PIN
/*
global Current_User_Name := Base_Array[User_Name]
global Current_User_Email := Val[2]
global Current_User_Pass := Val[3]
global Current_User_PIN := Val[4]
Current_User := Base_Array[User]
global Current_User_Name := Current_User.User_Name_new
global Current_User_Email := Current_User.User_Email
global Current_User_Pass := Current_User.User_Pass
global Current_User_PIN := Current_User.User_PIN
MsgBox, % Current_User.User_Name_new
. "`n " Current_User.User_Name_old
. "`n " Current_User.User_Email
. "`n " Current_User.User_Pass
. "`n " Current_User.User_PIN
*/
; Generate and combine text for account selection pop-up box
Output := "User: " User_Name " has: "
Output .= "Email: " User_Email " "
; Output .= "Password: " User_Pass " "
; Output .= "PIN: " User_PIN
; Switch_Account()
; OR
{
MsgBox, 3, , Login to %Output% ? (3 second Timeout & auto),3 ; 5
vRet := MsgBoxGetResult()
if ((vRet = "Yes") || (vRet = "Timeout"))
Switch_Account()
else if (vRet = "No")
goto END_of_user_loop
}
; Login_Password_PIN_BruteForce()
; loop, 2
if !Go_Back_To_Home_Screen()
Reload_LEWZ()
; ***************************************
; Main DEBUG and event Variables - START
; ***************************************
global Pause_Script := False ; Pause_Script := True
CSB_Event := True ; True ; True if CSB Event is going on
Desert_Event := False ; False ; True ; True if Desert Event is going on
; if CSB_Event ; || Desert_Event
At_War := False ; if set to True, peace shield will be enabled
; ***************************************
; Main DEBUG and event Variables - END
; ***************************************
; MsgBox, 4, , Enable Pause? (8 Second Timeout & skip), 5 ; 8
; vRet := MsgBoxGetResult()
; if (vRet = "Yes") ; || (vRet = "Timeout") || (vRet = "No")
; Pause_Script := True
if Pause_Script
{
MsgBox, 4, Pause script, Pause script? (5 Second Timeout & skip), 5 ; 5
vRet := MsgBoxGetResult()
if (vRet = "Yes") ; || (vRet = "Timeout") || (vRet = "No")
MsgBox, 0, Pause, Press OK to resume (No Timeout)
}
; Extract current UTC hour
Current_Hour_UTC := FormatTime(A_NowUTC, "HH")
Current_Day_UTC := FormatTime(A_NowUTC, "dddd")
Peace_Shield_Needed := False
; Figure out the day and time to determine if shield is needed
; If time is within 24 hours of killing event, Peace_Shield_Needed variable = True
if (Current_Day_UTC = "Friday") ; || (Current_Day_UTC = "Saturday") || (Current_Day_UTC = "Sunday"))
Peace_Shield_Needed := True
if At_War
Peace_Shield_Needed := True
; ###############################
; ###############################
; Peace_Shield_Needed := False
; ###############################
; ###############################
; Figure out time of day for which subroutines will run
if (Current_Hour_UTC >= 16 && Current_Hour_UTC < 24)
Routine := "End_Of_Day"
else if ((Current_Hour_UTC >= 24) || (Current_Hour_UTC <= 8))
Routine := "New_Day"
else
Routine := "Fast"
; if (Routine = "New_Day") ; || (Routine = "Fast") ; || (Routine = "End_Of_Day")
; Default defined routine
Routine_Set_Routine:
{
Routine_Running := Routine
; ******************************************
; DEBUG / Troubleshooting block - BEGIN
; add/remove or uncomment routines to check them
; ******************************************
; Speaker_Help()
; Adventure_Missions()
; Alliance_Boss_Feed()
; Speaker_Help()
; Active_Skill()
; Alliance_Wages()
; Speaker_Help()
/*
Speaker_Help()
MsgBox, 0, Pause, Press OK to end (No Timeout)
Go_Back_To_Home_Screen()
Alliance_Wages()
Active_Skill()
Speaker_Help()
; Go_Back_To_Home_Screen()
Gather_Resources()
goto END_of_user_loop
*/
; Goto_Coordinates(591,64)
; Goto_Coordinates()
; Login_Password_PIN_BruteForce()
; Check_Window_Geometry()
; Collect_Cafeteria()
; Collect_Chips_Underground()
; Collect_Collisions()
; Collect_Equipment_Crafting()
; Collect_Recruits()
; Collect_Red_Envelopes()
; Collect_Runes()
; Depot_Rewards()
; Desert_Oasis()
; Desert_Wonder()
; Donate_Tech()
; Drop_Zone()
; Game_Start_popups()
; Gather_On_Base_RSS()
; Gather_Resources()
; Get_Inventory()
; Get_User_Info()
; Get_User_Location()
; Golden_Chest()
; Mail_Collection()
; Peace_Shield()
; Golden_Chest()
; Speaker_Help()
; Benefits_Center()
; Active_Skill()
; Speaker_Help()
; Reserve_Factory()
; Speaker_Help()
; Send_Mail_To_Boss()
; Send_Message_In_Chat()
; Speaker_Help()
; Switch_Account()
; VIP_Shop()
; Reset_Posit()
; Reload_MEmu()
; Reload_LEWZ()
; Launch_LEWZ()
; Go_Back_To_Home_Screen()
; Login_Password_PIN_Enter()
; Login_Password_PIN_Find()
; Login_Password_PIN_Taps()
; Activity_Center_Open()
; Enter_Coordinates_From_Home()
; Enter_Coordinates_From_World()
; Enter_Coordinates_Open_Check()
; Check_For_Zombie_Popup()
; Select_App()
; Key_Menu()
; Benefits_Center()
; Active_Skill()
; Collect_Chips_Underground()
; Speaker_Help()
; Get_User_Location()
; Get_User_Info()
; Get_Inventory()
; Send_Mail_To_Boss()
; MsgBox, 0, Pause, Press OK to end (No Timeout)
; goto END_of_user_loop
; ******************************************
; DEBUG / Troubleshooting block - END
; ******************************************
; goto DEBUG_SKIP
; ****************************
; ** Position dependant **
; ****************************
if Peace_Shield_Needed
loop, 2
Peace_Shield()
; Reset_Posit()
Collect_Collisions()
Collect_Recruits()
Collect_Equipment_Crafting()
Collect_Runes()
Collect_Cafeteria()
Depot_Rewards()
Collect_Chips_Underground()
; if ((Routine = "New_Day") || (Routine = "End_Of_Day"))
; Golden_Chest()
Speaker_Help()
; if ((Routine = "New_Day") || (Routine = "End_Of_Day"))
Drop_Zone()
; ****************************
; ** Not position dependant **
; ****************************
/*
if CSB_Event ; || Desert_Event
if !(Current_Hour_UTC = 00 && A_Min <= 30)
Reserve_Factory()
*/
Active_Skill()
; Donate_tech()
Speaker_Help()
; if (Routine = "New_Day")
; {
VIP_Shop()
Benefits_Center()
Alliance_Boss_Feed()
; }
Speaker_Help()
; if (Routine = "End_Of_Day")
; {
Mail_Collection()
Alliance_Wages()
; }
; *************************
; DEBUG_SKIP:
; *************************
if Desert_Event
Desert_Oasis()
; Gather_Resources()
if Desert_Event
if ((Current_Day_UTC = "Saturday") || (Current_Day_UTC = "Sunday")) ; || ((Current_Day_UTC = "Friday")
if ((Routine = "New_Day") || (Routine = "End_Of_Day"))
Desert_Wonder()
Speaker_Help()
; Collect_Red_Envelopes()
; if !Desert_Event
; Gather_On_Base_RSS()
; if ((Current_Day_UTC = "Monday") || (Current_Day_UTC = "Tuesday") || (Current_Day_UTC = "Wednesday"))
; Gather_Resources()
Message_To_The_Boss := User_Name . " " . Routine . " Routine,"
; if ((Routine = "New_Day") || (Routine = "End_Of_Day"))
; Reset_Posit()
Get_User_Location()
; Collect_Recruits()
; Collect_Runes()
Get_User_Info()
Get_Inventory()
Send_Mail_To_Boss()
; Send_Message_In_Chat()
if Pause_Script
{
MsgBox, 4, Pause script, Pause before switching accounts? (5 Second Timeout & skip), 5 ; 5
vRet := MsgBoxGetResult()
if (vRet = "Yes") ; || (vRet = "Timeout") || (vRet = "No")
MsgBox, 0, Pause, Press OK to resume (No Timeout)
}
goto END_of_user_loop
}
; removed bulk of subroutines, to ease readability, no longer needed
Special_Routine:
New_Day_Game_Reset:
Fast_Routine:
End_Of_Day_Routine:
FULL_Q_and_A_Routine:
goto END_of_user_loop
F10::
; A_Index++
Continue
Switch_Account()
return
END_of_user_loop:
}
; start new log files
Refresh_LogFiles()
; relaunch LEWZ
; Reload_LEWZ()
; Launch_Lewz()
Gosub Reload_Script
if !Go_Back_To_Home_Screen()
Reload_LEWZ()
}
}
if !WinExist(FoundAppTitle)
return
else
{
; WinActivate ; The above IfWinNotExist also set the last found window for us.
WinMove, WinMove_X, WinMove_Y ; Move it to a new position.
return
}
MsgBox, Unexpected exit
;
Reload_LEWZ()
{
Reload_LEWZ_Kill()
Reload_LEWZ_Launch()
Account_Loading()
if !Go_Back_To_Home_Screen()
return 1
Else
return 0
}
Reload_LEWZ_Kill()
{
Gui, Status:new, , Status
Gui, Status:Margin, 0, 0
Gui, Status:add,text,, LEWZ Shutdown...
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
; loop, 2
{
; RunNoWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" connect 127.0.0.1:21513")
RunWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" connect 127.0.0.1:21513")
; RunNoWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" shell am force-stop com.longtech.lastwars.gp")
RunWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" shell am force-stop com.longtech.lastwars.gp")
DllCall("Sleep","UInt",(1*Delay_Long+0))
}
; DllCall("Sleep","UInt",(4*Delay_Long+0))
return
}
Reload_LEWZ_Launch()
{
Gui, Status:add,text,, LEWZ Startup...
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
; loop, 2
{
; RunNoWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" connect 127.0.0.1:21513")
RunWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" connect 127.0.0.1:21513")
; RunNoWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" shell monkey -p com.longtech.lastwars.gp -v 500")
RunWaitOne("""C:\Program Files\Microvirt\MEmu\adb.exe"" shell monkey -p com.longtech.lastwars.gp -v 500")
; DllCall("Sleep","UInt",(3*Delay_Long+0))
}
; DllCall("Sleep","UInt",(4*Delay_Long+0))
return
}
; Reload_MEmu() <--> Launch_LEWZ() <--> Go_Back_To_Home_Screen()
; Reload_MEmu() calls Launch_LEWZ() and NOT Go_Back_To_Home_Screen()
Reload_MEmu()
{
Subroutine_Running := "Reload_MEmu"
stdout.WriteLine(A_NowUTC ",Subroutine_Running," Subroutine_Running ",A_ThisLabel," A_ThisLabel ",StartTime," A_TickCount )
MEmu_Instance := "MEmu_1" ; MEmu_1 MEmu_2
Reload_MEmu_START:
Reload_MEmu_Kill()
; Reload_MEmu_Launch()
Loop, 10
{
Reload_MEmu_Launch()
; DllCall("Sleep","UInt",(rand_wait + 2*Delay_Long+0))
loop, 3
{
if Launch_LEWZ()
{
Gui, Status:add,text,, MEmu finished Loaded!!
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
Elivate_program()
return 1
}
Else
Reload_MEmu_Launch()
}
Gui, Status:add,text,, Reoading MEmu %A_Index%
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
Reload_MEmu_Kill()
; Reload_MEmu_Launch()
}
Gui, Status:add,text,, MEmu NOT Loaded!
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
goto Reload_MEmu_START
return 0
}
Reload_MEmu_Kill()
{
Gui, Status:new, , Status
Gui, Status:Margin, 0, 0
Gui, Status:add,text,, MEmu VM Shutdown...
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
loop, 2
{
RunNoWaitOne("""C:\Program Files\Microvirt\MEmu\MEmuConsole.exe"" ShutdownVm " . MEmu_Instance)
DllCall("Sleep","UInt",(3*Delay_Long+0))
}
DllCall("Sleep","UInt",(4*Delay_Long+0))
return
}
Reload_MEmu_Launch()
{
Gui, Status:add,text,, MEmu VM Startup...
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
loop, 2
{
RunNoWaitOne("""C:\Program Files\Microvirt\MEmu\MEmuConsole.exe"" " . MEmu_Instance)
DllCall("Sleep","UInt",(3*Delay_Long+0))
}
DllCall("Sleep","UInt",(4*Delay_Long+0))
return
}
; Launch_LEWZ() calls Go_Back_To_Home_Screen() and NOT Reload_MEmu()
; Launch LEWZ app from android main screen
Launch_LEWZ()
{
Subroutine_Running := "Launch_LEWZ"
stdout.WriteLine(A_NowUTC ",Subroutine_Running," Subroutine_Running ",A_ThisLabel," A_ThisLabel ",StartTime," A_TickCount )
; Gui, Status:new, , Status
; Gui, Status:Margin, 0, 0
; Gui, Status:add,text,, LEWZ loading...
; Gui, Status:show, x%MsgWinMove_X% y0 w300 h500
; Gui, Status:show, x731 y0 w300 h500
Launch_LEWZ_Click_Icon:
Select_App()
Check_Window_Geometry()
oIcon_LEWZSearch := new graphicsearch()
loop, 60
{
resultIcon_LEWZ := oIcon_LEWZSearch.search(011_Icon_LEWZ_Graphic, optionsObjCoords)
if (resultIcon_LEWZ)
{
loop, % resultIcon_LEWZ.Count()
{
Click_X := resultIcon_LEWZ[A_Index].x
Click_Y := resultIcon_LEWZ[A_Index].y
Gui, Status:add,text,, LEWZ icon found #%A_Index% (%Click_X%,%Click_Y%)
Mouse_Click(Click_X,Click_Y, {Clicks: 3,Timeout: (Delay_Medium+0)}) ; Tap LEWZ ICON
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
Icon_Found := True ; Goto Launch_LEWZ_Continue
break
}
}
; Else
; DllCall("Sleep","UInt",(1*Delay_Short+0))
Login_Password_PIN_Enter()
}
if Icon_Found
Goto Launch_LEWZ_Continue
Else
return 0
Launch_LEWZ_Continue:
Account_Loading()
if Go_Back_To_Home_Screen()
{
Gui, Status:add,text,, LEWZ Loaded!!
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
return 1
}
Else
{
Gui, Status:add,text,, Loading LEWZ %A_Index%
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
}
Gui, Status:add,text,, LEWZ NOT Loaded!
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
return 0
}
; Go_Back_To_Home_Screen() simple return a true or false value,
; if Quit dialog is detected after hitting the back button
; Go_Back_To_Home_Screen() calls neither Launch_LEWZ() NOR NOT Reload_MEmu()
; Go back until "Quit" dialog pop-ups, then make sure dialog goes away
Go_Back_To_Home_Screen()
{
Check_Window_Geometry()
loop, 10
{
Command_To_Screen("{F5}")
loop, 2
if Quit_GraphicSearch()
goto Go_Back_To_Home_Screen_OCR_NOT_Quit ; return 1
}
loop, 10
{
Check_Window_Geometry()
Command_To_Screen("{F5}")
loop, 3
if Quit_Rebuild_GraphicSearch()
goto Go_Back_To_Home_Screen_OCR_NOT_Quit ; return 1
if Quit_OCR()
goto Go_Back_To_Home_Screen_OCR_NOT_Quit ; return 1
}
return 0
Go_Back_To_Home_Screen_OCR_NOT_Quit:
Check_Window_Geometry()
Command_To_Screen("{F5}")
DllCall("Sleep","UInt",(1*Delay_Short+0))
loop, 30
if !Quit_GraphicSearch()
break
loop, 3
if !Quit_GraphicSearch()
return 1
loop, 10
{
Check_Window_Geometry()
Command_To_Screen("{F5}")
loop, 3
if !Quit_Rebuild_GraphicSearch()
return 1
if !Quit_OCR()
return 1
}
return 0
}
Quit_GraphicSearch() {
oGoBackSearch := new graphicsearch()
Quit_Graphics := 022_Quit_OK_Button_Graphic 021_Quit_Title_Graphic
; Check_Window_Geometry()
resultGoBack := oGoBackSearch.search(Quit_Graphics, optionsObjCoords)
if (resultGoBack)
return 1
return 0
}
Quit_Rebuild_GraphicSearch() {
oGoBackSearch := new graphicsearch()
oRebuildSearch := new graphicsearch()
Quit_Graphics := 022_Quit_OK_Button_Graphic 021_Quit_Title_Graphic
; Check_Window_Geometry()
resultGoBack := oGoBackSearch.search(Quit_Graphics, optionsObjCoords)
if (resultGoBack)
return 1
resultRebuild := oRebuildSearch.search(023_Rebuild_Button_Graphic, optionsObjCoords)
if (resultRebuild)
Mouse_Click(resultRebuild[1].x,resultRebuild[1].y, {Timeout: (2*Delay_Long+0)}) ; Tap "Rebuild" and wait
return 0
}
Quit_OCR()
{
; Check_Window_Geometry()
; OCR search for "quit" 151, 522 to 202, 554
Find_Quit := Search_Captured_Text_OCR(["Quit"], {Pos: [150, 520], Size: [50, 35]})
If (Find_Quit.Found)
return 1
return 0
}
; Clear in-game splash pages
Game_Start_popups()
{
Subroutine_Running := "Game_Start_popups"
stdout.WriteLine(A_NowUTC ",Subroutine_Running," Subroutine_Running ",A_ThisLabel," A_ThisLabel ",StartTime," A_TickCount )
; WinActivate, %FoundAppTitle% ; Automatically uses the window found above.
; Clear first pop-up by pressing back
Command_To_Screen("{F5}")
DllCall("Sleep","UInt",(rand_wait + 1*Delay_Long+0))
Mouse_Click(256,979, {Timeout: (1*Delay_Long+0)}) ; Check No More Prompts Today On Today'S Hot Sale
Mouse_Click(630,322, {Timeout: (1*Delay_Long+0)}) ; Tap X On Today'S Hot Sale
; Mouse_Click(379,736) ; Collect Cafeteria
if !Go_Back_To_Home_Screen()
Reload_LEWZ()
return
}
; reset position by going to world screen and back home, returns TRUE is successful, FALSE if unsuccessful
Reset_Posit()
{
Subroutine_Running := "Reset_Posit"
stdout.WriteLine(A_NowUTC ",Subroutine_Running," Subroutine_Running ",A_ThisLabel," A_ThisLabel ",StartTime," A_TickCount )
; WinActivate, %FoundAppTitle% ; Automatically uses the window found above.
; go back x times
; Go_Back_Home_Delay_Long := True
if !Go_Back_To_Home_Screen()
Reload_LEWZ()
; Tap World/home button x times ; Mouse_Click(76,1200, {Timeout: (6*Delay_Long+0)}) ; Tap World/home button
oWorldSearch := new graphicsearch()
; loop, 2
{
resultWorld := oWorldSearch.search(821_World_Button_Graphic, optionsObjCoords)
if (resultWorld)
{
Mouse_Click(resultWorld[1].x,resultWorld[1].y, {Timeout: (3*Delay_Short+0)})
loop, 40
{
resultWorld := oWorldSearch.search(822_Home_Button_Graphic, optionsObjCoords)
if (resultWorld)
{
Mouse_Click(resultWorld[1].x,resultWorld[1].y, {Timeout: (3*Delay_Short+0)})
goto, Reset_Posit_END
}
; Else
; DllCall("Sleep","UInt",(1*Delay_Short+0))
}
}
; Else
; DllCall("Sleep","UInt",(1*Delay_Short+0))
}
return 0
Reset_Posit_END:
; Go_Back_Home_Delay_Long := True
if !Go_Back_To_Home_Screen()
Reload_LEWZ()
return 1
}
; Login to account using stored credentials
Switch_Account()
{
Subroutine_Running := "Switch_Account"
stdout.WriteLine(A_NowUTC ",Subroutine_Running," Subroutine_Running ",A_ThisLabel," A_ThisLabel ",StartTime," A_TickCount )
Gui, Status:add,text,, ********************************
Gui, Status:add,text,, Switching to %User_Name%
; Gui, Status:show, x%MsgWinMove_X% y0 w300 h500
Gui, Status:show, x731 y0 w300 h500
GUI_Count+=2
oAccountSearch := new graphicsearch()
oLoginSearch := new graphicsearch()
allQueries_Account := 1A_Settings_Button_Graphic 1A1_Account_Button_Graphic 1A12_Switch_Button_Graphic 1A123_WarZ_Button_Graphic 1A1232_OtherAccount_Button_Graphic
allQueries_Login := 1A1234_Email_Box_Button_Graphic 1A1235_PW_Box_Button_Graphic 1A1237_UseEmailLog_Button_Graphic
Switch_Account_START:
if !Go_Back_To_Home_Screen()
Reload_LEWZ()
Mouse_Click(50,70, {Clicks: 1,Timeout: (1*Delay_Medium+0)}) ; Tap Commander Info
; check if any graphic was found
loop, 3
{
Mouse_Click(600,1200, {Timeout: (3*Delay_Short+0)}) ; "Settings" Button
Mouse_Click(100, 330, {Timeout: (3*Delay_Short+0)}) ; "Account" Button
Mouse_Click(330, 880, {Timeout: (3*Delay_Short+0)}) ; "Switch" Button
Mouse_Click(315, 720, {Timeout: (3*Delay_Short+0)}) ; "WarZ" Button
Mouse_Click(480,1150, {Timeout: (3*Delay_Short+0)}) ; "Other Account" button
loop, 20
{
resultLogin := oLoginSearch.search(allQueries_Login, optionsObjCoords)
if (resultLogin)
goto Switch_Account_Dialog
resultObj := oAccountSearch.search(allQueries_Account, optionsObjCoords)
if (resultObj)
Mouse_Click(resultObj[1].x,resultObj[1].y, {Timeout: (2*Delay_Short+0)})
if Search_Captured_Text_OCR(["Yes"], {Pos: [315, 860], Size: [60, 35]}).Found
{
MsgBox, 4, Yes Dialog, Press OK to resume (No Timeout)
Mouse_Click(340,870, {Timeout: (2*Delay_Short+0)}) ; Tap Yes
}
}
/*
Mouse_Click(600,1200, {Timeout: 0}) ; "Settings" Button
Mouse_Click(480,1150, {Timeout: 0}) ; "Other Account" button
DllCall("Sleep","UInt",(1*Delay_Short+0))
*/
}
goto Switch_Account_START
Switch_Account_Dialog:
oEmailSearch := new graphicsearch()
oPWSearch := new graphicsearch()
Gosub Switch_Account_User_Email
Gosub Switch_Account_User_Password
/*
loop, 5
{
if (oEmailSearch.search(1A1234_Email_Box_Button_Graphic, optionsObjCoords))
Gosub Switch_Account_User_Email
Else if (oPWSearch.search(1A1235_PW_Box_Button_Graphic, optionsObjCoords))
Gosub Switch_Account_User_Password
Else
goto Switch_Account_Next
}
goto Switch_Account_START
*/
loop, 5
{
resultEmail := oEmailSearch.search(1A1234_Email_Box_Button_Graphic, optionsObjCoords)
resultPW := oPWSearch.search(1A1235_PW_Box_Button_Graphic, optionsObjCoords)
if (resultEmail)
Gosub Switch_Account_User_Email
Else if (resultPW)
Gosub Switch_Account_User_Password
Else
goto Switch_Account_Next
}
goto Switch_Account_START
Switch_Account_User_Email:
{
; loop, 2
Mouse_Click(220,382, {Timeout: (2*Delay_Short+0)}) ; Tap inside Email Text Box
; DllCall("Sleep","UInt",(2*Delay_Short+0))
Check_Window_Geometry()
Text_To_Screen(User_Email)
DllCall("Sleep","UInt",(1*Delay_Short+0))
; DllCall("Sleep","UInt",(4*Delay_Short+0))
Command_To_Screen("{Enter}")
; DllCall("Sleep","UInt",(3*Delay_Short+0))
return
}
Switch_Account_User_Password:
{
; loop, 2
Mouse_Click(209,527, {Timeout: (2*Delay_Short+0)}) ; Tap inside Email Text Box
; DllCall("Sleep","UInt",(2*Delay_Short+0))
Check_Window_Geometry()
Text_To_Screen(User_Pass)
DllCall("Sleep","UInt",(1*Delay_Short+0))
; DllCall("Sleep","UInt",(4*Delay_Short+0))
Command_To_Screen("{Enter}")
; DllCall("Sleep","UInt",(3*Delay_Short+0))
return
}
Switch_Account_Next:
; DllCall("Sleep","UInt",(rand_wait + 1*Delay_Long+0))
; Mouse_Click(455,739, {Clicks: 2,Timeout: (1*Delay_Short+0)}) ; Tap Use your email to log in
Mouse_Click(455,739, {Timeout: (2*Delay_Short+0)}) ; Tap Use your email to log in
oGraphicSearch := new graphicsearch()
loop, 20
{
resultObj := oGraphicSearch.search(1A12371_OK_Button_Graphic, optionsObjCoords)
if (resultObj)
{
Gui, Status:add,text,, % "Found 1st ""OK"" loops:" A_Index
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
; loop, 2
Mouse_Click(resultObj[1].x,resultObj[1].y, {Timeout: (1*Delay_Short+0)}) ; Tap "OK"
Goto Switch_Account_OK2
}
if Search_Captured_Text_OCR(["Yes"], {Pos: [315, 860], Size: [60, 35]}).Found
{
MsgBox, 4, Yes Dialog, Press OK to resume (No Timeout)
Mouse_Click(340,870, {Timeout: (2*Delay_Short+0)}) ; Tap Yes
}
}
goto Switch_Account_START
Switch_Account_OK2:
oGraphicSearch := new graphicsearch()
loop, 10
{
resultObj := oGraphicSearch.search(1A12371_OK_Button_Graphic, optionsObjCoords)
if (resultObj)
{
Gui, Status:add,text,, % "Found 2nd ""OK"" loops:" A_Index
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
; loop, 2
Mouse_Click(resultObj[1].x,resultObj[1].y, {Timeout: (1*Delay_Short+0)}) ; Tap "OK"
Goto Switch_Account_Finish
}
if Search_Captured_Text_OCR(["Yes"], {Pos: [315, 860], Size: [60, 35]}).Found
{
MsgBox, 4, Yes Dialog, Press OK to resume (No Timeout)
Mouse_Click(340,870, {Timeout: (2*Delay_Short+0)}) ; Tap Yes
}
}
goto Switch_Account_START
Switch_Account_Finish:
Account_Loading()
; Switch_Account_END:
; Login_Password_PIN_Enter()
return
}
Account_Loading()
{
oGraphicSearch := new graphicsearch()
Loading_Text_Array := ["2nd","Anniversary","Arms","Base","Benefit","Celebrat","Center","Deal","Detail","Dio","Doomsday","element","Festival","Hot","Hunter","Invest","Iron","Master","Mutation","New","Officer","Online","Pack","Racer","relocat","Reynolds","Sale","state","Supply","Today","View","Wall","Weekly"]
Last_Game_Loading := "0"
loop, 10
{
resultObj := oGraphicSearch.search(1A12371_OK_Button_Graphic, optionsObjCoords)
if (resultObj)
Mouse_Click(resultObj[1].x,resultObj[1].y, {Timeout: (1*Delay_Short+0)}) ; Tap "OK"
if Search_Captured_Text_OCR(["Yes"], {Pos: [315, 860], Size: [60, 35]}).Found
{
MsgBox, 4, Yes Dialog, Press OK to resume (No Timeout)
Mouse_Click(340,870, {Timeout: (2*Delay_Short+0)}) ; Tap Yes
}
}
loop, 2 ; 60 ; 20
{
loop, 25
{
resultObj := oGraphicSearch.search(1A12371_OK_Button_Graphic, optionsObjCoords)
if (resultObj)
Mouse_Click(resultObj[1].x,resultObj[1].y, {Timeout: (1*Delay_Short+0)}) ; Tap "OK"
/*
if Search_Captured_Text_OCR(["Yes"], {Pos: [315, 860], Size: [60, 35]}).Found
{
MsgBox, 4, Yes Dialog, Press OK to resume (No Timeout)
Mouse_Click(340,870, {Timeout: (1*Delay_Short+0)}) ; Tap Yes
}
*/
Login_Password_PIN_Enter()
AccountLoading1 := Search_Captured_Text_OCR(Loading_Text_Array, {Pos: [190, 40], Size: [280, 42]}) ; 320, 42]})
AccountLoading2 := Search_Captured_Text_OCR(Loading_Text_Array, {Pos: [200, 305], Size: [300, 150]})
; AccountLoading := Search_Captured_Text_OCR(Loading_Text_Array, {Pos: [190, 40], Size: [310, 425]})
; 24, 195 to 133, 230
if ((AccountLoading1.Found) || (AccountLoading2.Found))
{
if (AccountLoading1.Found)
Gui, Status:add,text,, % " loops:" A_Index " Text1:""" AccountLoading1.Text """"
else if (AccountLoading2.Found)
Gui, Status:add,text,, % " loops:" A_Index " Text2:""" AccountLoading2.Text """"
; else
; goto try_again
Gui, Status:show, x731 y0 w300 h500
GUI_Count++
; MsgBox, 0, Text Found, % " index: " A_Index "`nText found: """ AccountLoading.Text """ (No Timeout)"
goto Switch_Account_PIN ; break
; try_again:
}
}
if !Go_Back_To_Home_Screen()
Reload_LEWZ()
else goto Switch_Account_PIN ; break
}