-
Notifications
You must be signed in to change notification settings - Fork 7
/
MyBot.run.MiniGui.au3
1686 lines (1465 loc) · 67.8 KB
/
MyBot.run.MiniGui.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
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
; #FUNCTION# ====================================================================================================================
; Name ..........: MBR Bot
; Description ...: This file contains the initialization and main loop sequences f0r the MBR Bot
; Author ........: cosote (2017)
; Modified ......:
; Remarks .......: This file is part of MyBot, previously known as ClashGameBot. Copyright 2015-2019
; MyBot is distributed under the terms of the GNU GPL
; Related .......:
; Link ..........: https://github.com/MyBotRun/MyBot/wiki
; Example .......: No
; ===============================================================================================================================
; AutoIt pragmas
#NoTrayIcon
#RequireAdmin
#AutoIt3Wrapper_UseX64=7n
;#AutoIt3Wrapper_Res_HiDpi=Y ; HiDpi will be set during run-time!
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/rsln /MI=3
;/SV=0
;#pragma compile(Console, true)
#include "MyBot.run.version.au3"
#pragma compile(ProductName, My Bot Mini Gui)
#pragma compile(Out, MyBot.run.MiniGui.exe) ; Required
; Enforce variable declarations
Opt("MustDeclareVars", 1)
Global $g_sBotTitle = "" ;~ Don't assign any title here, use Func UpdateBotTitle()
Global $g_hFrmBot = 0 ; The main GUI window
#include <APIErrorsConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>
#include <Misc.au3>
#include <ColorConstants.au3>
#include <Date.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <GuiToolTip.au3>
; Autoit Options
Opt("GUIResizeMode", $GUI_DOCKALL) ; Default resize mode for dock android support
Opt("GUIEventOptions", 1) ; Handle minimize and restore for dock android support
Opt("GUICloseOnESC", 0) ; Don't send the $GUI_EVENT_CLOSE message when ESC is pressed.
Opt("WinTitleMatchMode", 3) ; Window Title exact match mode
Opt("GUIOnEventMode", 1)
Global $hNtDll = DllOpen("ntdll.dll")
#cs
Global Const $COLOR_ERROR = $COLOR_RED ; Error messages
Global Const $COLOR_WARNING = $COLOR_MAROON ; Warning messages
Global Const $COLOR_INFO = $COLOR_BLUE ; Information or Status updates for user
Global Const $COLOR_SUCCESS = 0x006600 ; Dark Green, Action, method, or process completed successfully
Global Const $COLOR_DEBUG = $COLOR_PURPLE ; Purple, basic debug color
#ce
; Global Variables
;Global $g_bRunState = True
Global $g_iGlobalActiveBotsAllowed = 0 ; Dummy
Global $g_hMutextOrSemaphoreGlobalActiveBots = 0 ; Dummy
Global $g_hStatusBar = 0 ; Dummy
Global $hMutex_BotTitle = 0 ; Mutex handle for this instance
Global $hStarted = 0 ; Timer handle watchdog started
Global $bCloseWhenAllBotsUnregistered = True ; Automatically close watchdog when all bots closed
Global $iTimeoutBroadcast = 30000 ; Milliseconds of sending broadcast messages to bots
Global $iTimeoutCheckBot = 5000 ; Milliseconds bots are checked if restart required
Global $iTimeoutRestartBot = 120000 ; Milliseconds un-responsive bot is launched again
Global $iTimeoutAutoClose = 60000 ; Milliseconds watchdog automatically closed when no bot available, -1 = disabled
Global $hTimeoutAutoClose = 0 ; Timer Handle for $iTimeoutAutoClose
Global $g_iMainLoopSleep = 50 ;
;Global $g_bBotLaunchOption_NoBotSlot = True
; Custom - Team__AiO__MOD
Global $g_bAutoDockMiniGUI = True
Global $g_hAndroidHandleMini = 0
Global $g_sEmulatorNameMini = ""
Global $g_sBotTitle = "My Bot Mini " & $g_sBotVersion & " - " & "AiO++ MOD " & $g_sModVersion & " -" ;~ Don't use any non file name supported characters like \ / : * ? " < > |
Global $g_hFrmBot = 0
Global $g_hFrmBotBackend = 0
Global $g_bBotLaunched = False
Global $g_iBotBackendFindTimeout = 3000
Global $hStruct_SleepMicro = DllStructCreate("int64 time;")
Global $pStruct_SleepMicro = DllStructGetPtr($hStruct_SleepMicro)
Global $DELAYSLEEP = 10
Global $DELAYWINDOWSARRANGE1 = 100
Global $g_iDebugSetlog = 0
Global $g_hFrmBotEmbeddedMouse = 0
; MBR includes
#include "COCBot\MBR Global Variables.au3"
#include "COCBot\functions\Other\ExtendedErrorInfo.au3"
#include "COCBot\functions\Other\MBRFunc.au3"
#include "COCBot\functions\Other\DissociableFunc.au3"
#include "COCBot\functions\Other\Multilanguage.au3"
#include "COCBot\functions\Other\Base64.au3"
#include "COCBot\functions\Other\Api.au3"
#include "COCBot\functions\Other\ApiHost.au3"
#include "COCBot\functions\Other\LaunchConsole.au3"
#include "COCBot\functions\Other\Time.au3"
#include "COCBot\functions\Other\WindowsArrange.au3"
#include "COCBot\MBR GUI Design Mini.au3"
#include "COCBot\functions\Config\readConfig.au3"
; Team AiO MOD++ (2019)
#include "COCBot\Team__AiO__MOD++\functions\Config\readConfig.au3"
#include "COCBot\functions\Other\UpdateStats.Mini.au3"
#include "COCBot\functions\Other\_NumberFormat.au3"
; Only farm - Team AiO MOD++
Func ApplyMiniCFG($TypeReadSave = "Read")
$g_bApplyConfigIsActive = True
If $g_iGuiMode = 2 Then ; mini mode controls
Switch $TypeReadSave
Case "Read"
GUICtrlSetState($g_hChkBackgroundMode, $g_bChkBackgroundMode = True ? $GUI_CHECKED : $GUI_UNCHECKED)
; <><><> Only Farm <><><>
_GUICtrlComboBox_SetCurSel($g_hCmbStatusMode, $g_iComboStatusMode)
ComboStatusMode()
Case "Save"
$g_bChkBackgroundMode = (GUICtrlRead($g_hChkBackgroundMode) = $GUI_CHECKED)
; <><><> Only Farm <><><>
$g_iComboStatusMode = Number(_GUICtrlComboBox_GetCurSel($g_hCmbStatusMode))
EndSwitch
EndIf
$g_bApplyConfigIsActive = False
EndFunc ;==>ApplyMiniCFG
Func SaveMiniCFG()
; <><><><> Village / Misc <><><><>
ApplyMiniCFG("Save")
; <><><><> Bottom panel <><><><>
IniWrite($g_sProfileConfigPath, "general", "Background", $g_bChkBackgroundMode ? 1 : 0)
; <><><> Only Farm <><><>
IniWrite($g_sProfileConfigPath, "general", "ComboStatusMode", Abs(Number($g_iComboStatusMode)))
EndFunc ;==>SaveMiniCFG
Func ComboStatusMode()
If IsDeclared("g_iComboStatusMode") Then
Local $iStatusFlag = 2, $iNewStatus = 2
If $g_bChkOnlyFarm = True Then $iStatusFlag += 8
If $g_bOnlyBuilderBase = True Then $iStatusFlag += 16
$g_bChkOnlyFarm = False
$g_bOnlyBuilderBase = False
Switch _GUICtrlComboBox_GetCurSel($g_hCmbStatusMode)
Case 1
$g_iComboStatusMode = 1
$g_bChkOnlyFarm = True
$iNewStatus += 8
Case 2
$g_iComboStatusMode = 2
$g_bChkOnlyFarm = False
$g_bOnlyBuilderBase = True
$iNewStatus += 16
$g_iCurrentReport = $g_iBBReport
btnVillageStat()
Case Else
$g_bChkOnlyFarm = False
$g_bOnlyBuilderBase = False
$g_iComboStatusMode = 0
Return
EndSwitch
; Quick solution.
If $iStatusFlag = $iNewStatus Then Return
$g_bRestart = True
EndIf
EndFunc ;==>ComboStatusMode
Global Enum $eBotUpdateStats = $eBotClose + 1
Func SetLog($String, $Color = $COLOR_BLACK, $LogPrefix = "L ")
Local $log = $LogPrefix & TimeDebug() & $String
_ConsoleWrite($log & @CRLF) ; Always write any log to console
EndFunc ;==>SetLog
Func SetDebugLog($String, $Color = $COLOR_DEBUG, $LogPrefix = "D ")
Return SetLog($String, $Color, $LogPrefix)
EndFunc ;==>SetDebugLog
Func _Sleep($ms, $iSleep = True, $CheckRunState = True)
CheckBotRequests() ; check if bot window should be moved, minized etc.
_SleepMilli($ms)
EndFunc ;==>_Sleep
Func _SleepMicro($iMicroSec)
;Local $hStruct_SleepMicro = DllStructCreate("int64 time;")
;Local $pStruct_SleepMicro = DllStructGetPtr($hStruct_SleepMicro)
DllStructSetData($hStruct_SleepMicro, "time", $iMicroSec * -10)
DllCall($hNtDll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pStruct_SleepMicro)
;$hStruct_SleepMicro = 0
EndFunc ;==>_SleepMicro
Func UpdateBotTitle($sTitle = "My Bot " & $g_sBotVersion)
$sTitle = StringReplace($sTitle, "My Bot", "My Bot Mini")
If $g_sBotTitle = $sTitle Then Return
$g_sBotTitle = $sTitle
If $g_hFrmBot <> 0 Then
; Update Bot Window Title also
WinSetTitle($g_hFrmBot, "", $g_sBotTitle)
GUICtrlSetData($g_hLblBotTitle, $g_sBotTitle)
EndIf
; Update Console Window (if it exists)
DllCall("kernel32.dll", "bool", "SetConsoleTitle", "str", "Console " & $g_sBotTitle)
; Update try icon title
TraySetToolTip($g_sBotTitle)
GUISetIcon($g_sLibModIconPath, $eIcnAIOMod)
SetDebugLog("Bot title updated to: " & $g_sBotTitle)
EndFunc ;==>UpdateBotTitle
Func _SleepMilli($iMilliSec)
_SleepMicro(Int($iMilliSec * 1000))
EndFunc ;==>_SleepMilli
; added to avoid SciTE warning
Func ResumeAndroid()
EndFunc ;==>ResumeAndroid
Func ProcessCommandLine()
; Handle Command Line Launch Options and fill $g_asCmdLine
If $CmdLine[0] > 0 Then
SetDebugLog("Full Command Line: " & _ArrayToString($CmdLine, " "))
For $i = 1 To $CmdLine[0]
Local $bOptionDetected = True
Switch $CmdLine[$i]
; terminate bot if it exists (by window title!)
Case "/restart", "/r", "-restart", "-r"
$g_bBotLaunchOption_Restart = True
Case "/autostart", "/a", "-autostart", "-a"
$g_bBotLaunchOption_Autostart = True
Case "/nowatchdog", "/nwd", "-nowatchdog", "-nwd"
$g_bBotLaunchOption_NoWatchdog = True
Case "/dpiaware", "/da", "-dpiaware", "-da"
$g_bBotLaunchOption_ForceDpiAware = True
Case "/dock1", "/d1", "-dock1", "-d1", "/dock", "/d", "-dock", "-d"
$g_iBotLaunchOption_Dock = 1
Case "/dock2", "/d2", "-dock2", "-d2"
$g_iBotLaunchOption_Dock = 2
Case "/nobotslot", "/nbs", "-nobotslot", "-nbs"
$g_bBotLaunchOption_NoBotSlot = True
Case "/debug", "/debugmode", "/dev", "-debug", "-dev"
$g_bDevMode = True
$g_bDOCRDebugImages = True And $g_bDOCRDebugImages
Case "/minigui", "/mg", "-minigui", "-mg"
$g_iGuiMode = 2
Case "/nogui", "/ng", "-nogui", "-ng"
$g_iGuiMode = 0
Case "/console", "/c", "-console", "-c"
_WinAPI_AllocConsole()
_WinAPI_SetConsoleIcon($g_sLibIconPath, $eIcnGUI)
Case Else
If StringInStr($CmdLine[$i], "/guipid=") Then
Local $guidpid = Int(StringMid($CmdLine[$i], 9))
If ProcessExists($guidpid) Then
$g_iGuiPID = $guidpid
Else
SetDebugLog("GUI Process doesn't exist: " & $guidpid)
EndIf
Else
$bOptionDetected = False
$g_asCmdLine[0] += 1
ReDim $g_asCmdLine[$g_asCmdLine[0] + 1]
$g_asCmdLine[$g_asCmdLine[0]] = $CmdLine[$i]
EndIf
EndSwitch
If $bOptionDetected Then SetDebugLog("Command Line Option detected: " & $CmdLine[$i])
Next
EndIf
; Handle Command Line Parameters
If $g_asCmdLine[0] > 0 Then
$g_sProfileCurrentName = StringRegExpReplace($g_asCmdLine[1], '[/:*?"<>|]', '_')
If $g_asCmdLine[0] >= 2 Then
If StringInStr($g_asCmdLine[2], "BlueStacks3") Then $g_asCmdLine[2] = "BlueStacks2"
EndIf
ElseIf FileExists($g_sProfilePath & "\profile.ini") Then
$g_sProfileCurrentName = StringRegExpReplace(IniRead($g_sProfilePath & "\profile.ini", "general", "defaultprofile", ""), '[/:*?"<>|]', '_')
If $g_sProfileCurrentName = "" Or Not FileExists($g_sProfilePath & "\" & $g_sProfileCurrentName) Then $g_sProfileCurrentName = "<No Profiles>"
Else
$g_sProfileCurrentName = "<No Profiles>"
EndIf
EndFunc ;==>ProcessCommandLine
Func InitializeAndroid()
Local $s = GetTranslatedFileIni("MBR GUI Design - Loading", "StatusBar_Item_06", "Initializing Android...")
SplashStep($s)
If $g_bBotLaunchOption_Restart = False Then
; initialize Android config
InitAndroidConfig(True)
; Change Android type and update variable
If $g_asCmdLine[0] > 1 Then
Local $i
For $i = 0 To UBound($g_avAndroidAppConfig) - 1
If StringCompare($g_avAndroidAppConfig[$i][0], $g_asCmdLine[2]) = 0 Then
$g_iAndroidConfig = $i
SplashStep($s & "(" & $g_avAndroidAppConfig[$i][0] & ")...", False)
If $g_avAndroidAppConfig[$i][1] <> "" And $g_asCmdLine[0] > 2 Then
; Use Instance Name
UpdateAndroidConfig($g_asCmdLine[3])
Else
UpdateAndroidConfig()
EndIf
SplashStep($s & "(" & $g_avAndroidAppConfig[$i][0] & ")", False)
ExitLoop
EndIf
Next
EndIf
SplashStep(GetTranslatedFileIni("MBR GUI Design - Loading", "StatusBar_Item_07", "Detecting Android..."))
If $g_asCmdLine[0] < 2 Then
;mini DetectRunningAndroid()
;mini If Not $g_bFoundRunningAndroid Then DetectInstalledAndroid()
EndIf
Else
; just increase step
SplashStep($s)
EndIf
;mini CleanSecureFiles()
;mini GetCOCDistributors() ; realy load of distributors to prevent rare bot freeze during boot
EndFunc ;==>InitializeAndroid
Func InitAndroidConfig($bRestart = False)
If $bRestart = False Then
$g_sAndroidEmulator = $g_avAndroidAppConfig[$g_iAndroidConfig][0]
$g_sAndroidInstance = $g_avAndroidAppConfig[$g_iAndroidConfig][1]
$g_sAndroidTitle = $g_avAndroidAppConfig[$g_iAndroidConfig][2]
EndIf
$g_sAppClassInstance = $g_avAndroidAppConfig[$g_iAndroidConfig][3] ; Control Class and instance of android rendering
$g_sAppPaneName = $g_avAndroidAppConfig[$g_iAndroidConfig][4] ; Control name of android rendering TODO check is still required
$g_iAndroidClientWidth = $g_avAndroidAppConfig[$g_iAndroidConfig][5] ; Expected width of android rendering control
$g_iAndroidClientHeight = $g_avAndroidAppConfig[$g_iAndroidConfig][6] ; Expected height of android rendering control
$g_iAndroidWindowWidth = $g_avAndroidAppConfig[$g_iAndroidConfig][7] ; Expected Width of android window
$g_iAndroidWindowHeight = $g_avAndroidAppConfig[$g_iAndroidConfig][8] ; Expected height of android window
$g_iAndroidAdbSuCommand = "" ; Android path to su
$g_sAndroidAdbPath = "" ; Path to executable HD-Adb.exe or adb.exe
$g_sAndroidAdbDevice = $g_avAndroidAppConfig[$g_iAndroidConfig][10] ; full device name ADB connects to
$g_iAndroidSupportFeature = $g_avAndroidAppConfig[$g_iAndroidConfig][11] ; 0 = Not available, 1 = Available, 2 = Available using ADB (experimental!)
$g_sAndroidShellPrompt = $g_avAndroidAppConfig[$g_iAndroidConfig][12] ; empty string not available, '# ' for rooted and '$ ' for not rooted android
$g_sAndroidMouseDevice = $g_avAndroidAppConfig[$g_iAndroidConfig][13] ; empty string not available, can be direct device '/dev/input/event2' or name by getevent -p
$g_iAndroidEmbedMode = $g_avAndroidAppConfig[$g_iAndroidConfig][14] ; Android Dock Mode: -1 = Not available, 0 = Normal docking, 1 = Simulated docking
$g_iAndroidBackgroundModeDefault = $g_avAndroidAppConfig[$g_iAndroidConfig][15] ; Default Android Background Mode: 1 = WinAPI mode (faster, but requires Android DirectX), 2 = ADB screencap mode (slower, but alwasy works even if Monitor is off -> "True Brackground Mode")
$g_bAndroidAdbScreencap = $g_bAndroidAdbScreencapEnabled = True And BitAND($g_iAndroidSupportFeature, 2) = 2 ; Use Android ADB to capture screenshots in RGBA raw format
$g_bAndroidAdbClick = $g_bAndroidAdbClickEnabled = True And AndroidAdbClickSupported() ; Enable Android ADB mouse click
$g_bAndroidAdbInput = $g_bAndroidAdbInputEnabled = True And BitAND($g_iAndroidSupportFeature, 8) = 8 ; Enable Android ADB send text (CC requests)
$g_bAndroidAdbInstance = $g_bAndroidAdbInstanceEnabled = True And BitAND($g_iAndroidSupportFeature, 16) = 16 ; Enable Android steady ADB shell instance when available
$g_bAndroidAdbClickDrag = $g_bAndroidAdbClickDragEnabled = True And BitAND($g_iAndroidSupportFeature, 32) = 32 ; Enable Android ADB Click Drag script or input swipe
$g_bAndroidEmbed = $g_bAndroidEmbedEnabled = True And $g_iAndroidEmbedMode > -1 ; Enable Android Docking
$g_bAndroidBackgroundLaunch = $g_bAndroidBackgroundLaunchEnabled = True ; Enabled Android Background launch using Windows Scheduled Task
$g_bAndroidBackgroundLaunched = False ; True when Android was launched in headless mode without a window
$g_bUpdateAndroidWindowTitle = False ; If Android has always same title (like LeapDroid) instance name will be added
; screencap might have disabled backgroundmode
If $g_bAndroidAdbScreencap And IsDeclared("g_hChkBackground") Then
; when GUI is initialized, update background checkbox
chkBackground()
EndIf
UpdateHWnD($g_hAndroidWindow, False) ; Ensure $g_sAppClassInstance is properly set
EndFunc ;==>InitAndroidConfig
Func UpdateAndroidConfig($instance = Default, $emulator = Default)
If $emulator <> Default Then
; Update $g_iAndroidConfig
For $i = 0 To UBound($g_avAndroidAppConfig) - 1
If $g_avAndroidAppConfig[$i][0] = $emulator Then
If $g_iAndroidConfig <> $i Then
$g_iAndroidConfig = $i
$g_sAndroidEmulator = $g_avAndroidAppConfig[$g_iAndroidConfig][0]
SetLog("Android Emulator " & $g_sAndroidEmulator)
EndIf
$emulator = Default
ExitLoop
EndIf
Next
EndIf
If $emulator <> Default Then SetLog("Unknown Android Emulator " & $emulator, $COLOR_RED)
If $instance = "" Then $instance = Default
If $instance = Default Then $instance = $g_avAndroidAppConfig[$g_iAndroidConfig][1]
SetDebugLog("UpdateAndroidConfig(""" & $instance & """)")
InitAndroidConfig(False)
$g_sAndroidInstance = $instance ; Clone or instance of emulator or "" if not supported/default instance
; update secure setting
If BitAND($g_iAndroidSecureFlags, 1) = 1 Then
$g_sAndroidPicturesHostFolder = ""
Else
$g_sAndroidPicturesHostFolder = "mybot.run\"
EndIf
; validate install and initialize Android variables
Local $Result = InitAndroid(False, False)
SetDebugLog("UpdateAndroidConfig(""" & $instance & """) END")
Return $Result
EndFunc ;==>UpdateAndroidConfig
Func AndroidAdbClickSupported()
Return BitAND($g_iAndroidSupportFeature, 4) = 4
EndFunc ;==>AndroidAdbClickSupported
Func InitAndroid($bCheckOnly = False, $bLogChangesOnly = True)
If $bCheckOnly = False And $g_bInitAndroid = False Then
;SetDebugLog("InitAndroid(" & $bCheckOnly & "): " & $g_sAndroidEmulator & " is already initialized");
Return True
EndIf
$g_bInitAndroidActive = True
Local $aPriorValues = [ _
$g_sAndroidEmulator _
, $g_iAndroidConfig _
, $g_sAndroidVersion _
, $g_sAndroidInstance _
, $g_sAndroidTitle _
, $g_sAndroidProgramPath _
, GetAndroidProgramParameter() _
, ((IsArray($g_avAndroidProgramFileVersionInfo) ? _ArrayToString($g_avAndroidProgramFileVersionInfo, ",", 1) : "not available")) _
, $g_iAndroidSecureFlags _
, $g_sAndroidAdbPath _
, $g_sAndroidAdbGlobalOptions _
, $__VBoxManage_Path _
, $g_sAndroidAdbDevice _
, $g_sAndroidPicturesPath _
, $g_sAndroidPicturesHostPath _
, $g_sAndroidPicturesHostFolder _
, $g_sAndroidMouseDevice _
, $g_bAndroidAdbScreencap _
, $g_bAndroidAdbInput _
, $g_bAndroidAdbClick _
, $g_bAndroidAdbClickDrag _
, ($g_bChkBackgroundMode = True ? "enabled" : "disabled") _
, $g_bNoFocusTampering _
]
SetDebugLog("InitAndroid(" & $bCheckOnly & "): " & $g_sAndroidEmulator)
If Not $bCheckOnly Then
; Check that $g_sAndroidInstance default instance is used for ""
If $g_sAndroidInstance = "" Then $g_sAndroidInstance = $g_avAndroidAppConfig[$g_iAndroidConfig][1]
; clear some values for optional vbox calls
$__VBoxGuestProperties = ""
$__VBoxExtraData = ""
EndIf
; call Android initialization routine
Local $Result = Execute("Init" & $g_sAndroidEmulator & "(" & $bCheckOnly & ")")
If $Result = "" And @error <> 0 Then
; Not implemented
SetLog("Android support for " & $g_sAndroidEmulator & " is not available", $COLOR_ERROR)
EndIf
Local $successful = @error = 0, $process_killed
If Not $bCheckOnly And $Result Then
; exclude Android for WerFault reporting
If $b_sAndroidProgramWerFaultExcluded = True Then
Local $sFileOnly = StringMid($g_sAndroidProgramPath, StringInStr($g_sAndroidProgramPath, "\", 0, -1) + 1)
Local $aResult = DllCall("Wer.dll", "int", "WerAddExcludedApplication", "wstr", $sFileOnly, "bool", True)
If (UBound($aResult) > 0 And $aResult[0] = $S_OK) Or RegWrite($g_sHKLM & "\Software\Microsoft\Windows\Windows Error Reporting\ExcludedApplications", $sFileOnly, "REG_DWORD", "1") = 1 Then
SetDebugLog("Disabled WerFault for " & $sFileOnly)
Else
SetDebugLog("Cannot disable WerFault for " & $sFileOnly)
EndIf
EndIf
; update Virtualbox properties
If FileExists($__VBoxManage_Path) Then
If $__VBoxGuestProperties = "" Then $__VBoxGuestProperties = LaunchConsole($__VBoxManage_Path, "guestproperty enumerate " & $g_sAndroidInstance, $process_killed)
If $__VBoxExtraData = "" Then $__VBoxExtraData = LaunchConsole($__VBoxManage_Path, "getextradata " & $g_sAndroidInstance & " enumerate", $process_killed)
EndIf
UpdateAndroidBackgroundMode()
; read Android Program Details
Local $pAndroidFileVersionInfo
If _WinAPI_GetFileVersionInfo($g_sAndroidProgramPath, $pAndroidFileVersionInfo) Then
$g_avAndroidProgramFileVersionInfo = _WinAPI_VerQueryValue($pAndroidFileVersionInfo)
Else
$g_avAndroidProgramFileVersionInfo = 0
EndIf
Local $i = 0
Local $sText = ""
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidEmulator) Or $bLogChangesOnly = False Then SetDebugLog("Android: " & $g_sAndroidEmulator)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_iAndroidConfig) Or $bLogChangesOnly = False Then SetDebugLog("Android Config: " & $g_iAndroidConfig)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidVersion) Or $bLogChangesOnly = False Then SetDebugLog("Android Version: " & $g_sAndroidVersion)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidInstance) Or $bLogChangesOnly = False Then SetDebugLog("Android Instance: " & $g_sAndroidInstance)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidTitle) Or $bLogChangesOnly = False Then SetDebugLog("Android Window Title: " & $g_sAndroidTitle)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidProgramPath) Or $bLogChangesOnly = False Then SetDebugLog("Android Program Path: " & $g_sAndroidProgramPath)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], GetAndroidProgramParameter()) Or $bLogChangesOnly = False Then SetDebugLog("Android Program Parameter: " & GetAndroidProgramParameter())
$sText = ((IsArray($g_avAndroidProgramFileVersionInfo) ? _ArrayToString($g_avAndroidProgramFileVersionInfo, ",", 1) : "not available"))
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $sText) Or $bLogChangesOnly = False Then SetDebugLog("Android Program FileVersionInfo: " & $sText)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_iAndroidSecureFlags) Or $bLogChangesOnly = False Then SetDebugLog("Android SecureME setting: " & $g_iAndroidSecureFlags)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidAdbPath) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Path: " & $g_sAndroidAdbPath)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidAdbGlobalOptions) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Global Options: " & $g_sAndroidAdbGlobalOptions)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $__VBoxManage_Path) Or $bLogChangesOnly = False Then SetDebugLog("Android VBoxManage Path: " & $__VBoxManage_Path)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidAdbDevice) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Device: " & $g_sAndroidAdbDevice)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidPicturesPath) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Shared Folder: " & $g_sAndroidPicturesPath)
; check if share folder exists
If FileExists($g_sAndroidPicturesHostPath) Then
If ($g_sAndroidPicturesHostFolder <> "" Or BitAND($g_iAndroidSecureFlags, 1) = 1) Then
DirCreate($g_sAndroidPicturesHostPath & $g_sAndroidPicturesHostFolder)
EndIf
ElseIf $g_sAndroidPicturesHostPath <> "" Then
SetLog("Shared Folder doesn't exist, please fix:", $COLOR_ERROR)
SetLog($g_sAndroidPicturesHostPath, $COLOR_ERROR)
EndIf
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidPicturesHostPath) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Shared Folder on Host: " & $g_sAndroidPicturesHostPath)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidPicturesHostFolder) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Shared SubFolder: " & $g_sAndroidPicturesHostFolder)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_sAndroidMouseDevice) Or $bLogChangesOnly = False Then SetDebugLog("Android Mouse Device: " & $g_sAndroidMouseDevice)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_bAndroidAdbScreencap) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB screencap command enabled: " & $g_bAndroidAdbScreencap)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_bAndroidAdbInput) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB input command enabled: " & $g_bAndroidAdbInput)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_bAndroidAdbClick) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Mouse Click enabled: " & $g_bAndroidAdbClick)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_bAndroidAdbClickDrag) Or $bLogChangesOnly = False Then SetDebugLog("Android ADB Click Drag enabled: " & $g_bAndroidAdbClickDrag)
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], ($g_bChkBackgroundMode = True ? "enabled" : "disabled")) Or $bLogChangesOnly = False Then SetDebugLog("Bot Background Mode for screen capture: " & ($g_bChkBackgroundMode = True ? "enabled" : "disabled"))
If CompareAndUpdate($aPriorValues[IncrUpdate($i)], $g_bNoFocusTampering) Or $bLogChangesOnly = False Then SetDebugLog("No Focus Tampering: " & $g_bNoFocusTampering)
;$g_hAndroidWindow = WinGetHandle($g_sAndroidTitle) ;Handle for Android window
WinGetAndroidHandle() ; Set $g_hAndroidWindow and $g_sAndroidTitle for Android window
InitAndroidTimeLag()
InitAndroidPageError()
$g_bInitAndroid = Not $successful
Else
If $bCheckOnly = False Then $g_bInitAndroid = True
EndIf
SetDebugLog("InitAndroid(" & $bCheckOnly & "): " & $g_sAndroidEmulator & " END, initialization successful = " & $successful & ", result = " & $Result)
$g_bInitAndroidActive = False
Return $Result
EndFunc ;==>InitAndroid
Func IncrUpdate(ByRef $i, $ReturnInitial = True)
Local $i2 = $i
$i += 1
If $ReturnInitial Then Return $i2
Return $i
EndFunc ;==>IncrUpdate
Func CompareAndUpdate(ByRef $UpdateWhenDifferent, Const $New)
Local $bDifferent = $UpdateWhenDifferent <> $New
If $bDifferent Then $UpdateWhenDifferent = $New
Return $bDifferent
EndFunc ;==>CompareAndUpdate
Func GetVersionNormalized($VersionString, $Chars = 5)
If StringLeft($VersionString, 1) = "v" Then $VersionString = StringMid($VersionString, 2)
Local $a = StringSplit($VersionString, ".", 2)
Local $i
For $i = 0 To UBound($a) - 1
If StringLen($a[$i]) < $Chars Then $a[$i] = _StringRepeat("0", $Chars - StringLen($a[$i])) & $a[$i]
Next
Return _ArrayToString($a, ".")
EndFunc ;==>GetVersionNormalized
Func InitAndroidTimeLag()
EndFunc ;==>InitAndroidTimeLag
Func InitAndroidPageError()
EndFunc ;==>InitAndroidPageError
Func UpdateHWnD($hWin, $bRestart = True)
EndFunc ;==>UpdateHWnD
Func GetAndroidProgramParameter()
Return ""
EndFunc ;==>GetAndroidProgramParameter
Func BotMoveRequest()
$g_bBotMoveRequested = True
EndFunc ;==>BotMoveRequest
Func BotMinimizeRequest()
BotMinimize("MinimizeButton", False, 500)
EndFunc ;==>BotMinimizeRequest
Func UpdateAndroidBackgroundMode()
EndFunc ;==>UpdateAndroidBackgroundMode
Func readWeakBaseStats()
EndFunc ;==>readWeakBaseStats
Func BotMinimizeRestore($bMinimize, $sCaller, $iForceUpdatingWhenMinimized = False, $iStayMinimizedMillis = 0)
Static $siStayMinimizedMillis = 0
Static $shStayMinimizedTimer = 0
If $bMinimize Then
If $iStayMinimizedMillis > 0 Then
$siStayMinimizedMillis = $iStayMinimizedMillis
$shStayMinimizedTimer = __TimerInit()
EndIf
;Local $hMutex = AcquireMutex("MinimizeRestore")
If $g_bAndroidEmbedded = True And $g_bChkBackgroundMode = False Then
; don't minimize bot when embedded and background mode is off
;ReleaseMutex($hMutex)
Return False
EndIf
SetDebugLog("Minimize bot window, caller: " & $sCaller, Default, True)
$g_bFrmBotMinimized = True
If $g_bUpdatingWhenMinimized Or $iForceUpdatingWhenMinimized = True Then
If $g_bHideWhenMinimized Then
WinMove2($g_hFrmBot, "", -32000, -32000, -1, -1, 0, $SWP_HIDEWINDOW, False)
_WinAPI_SetWindowLong($g_hFrmBot, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($g_hFrmBot, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW))
EndIf
If _WinAPI_IsIconic($g_hFrmBot) Then WinSetState($g_hFrmBot, "", @SW_RESTORE)
If _WinAPI_IsIconic($g_hAndroidWindow) Then WinSetState($g_hAndroidWindow, "", @SW_RESTORE)
WinMove2($g_hFrmBot, "", -32000, -32000, -1, -1, 0, $SWP_SHOWWINDOW, False)
Else
If $g_bHideWhenMinimized Then
WinMove2($g_hFrmBot, "", -1, -1, -1, -1, 0, $SWP_HIDEWINDOW, False)
_WinAPI_SetWindowLong($g_hFrmBot, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($g_hFrmBot, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW))
EndIf
WinSetState($g_hFrmBot, "", @SW_MINIMIZE)
;WinSetState($g_hAndroidWindow, "", @SW_MINIMIZE)
EndIf
;ReleaseMutex($hMutex)
Return True
EndIf
If $siStayMinimizedMillis > 0 And __TimerDiff($shStayMinimizedTimer) < $siStayMinimizedMillis Then
SetDebugLog("Prevent Bot Window Restore")
Return False
Else
$siStayMinimizedMillis = 0
$shStayMinimizedTimer = 0
EndIf
;Local $hMutex = AcquireMutex("MinimizeRestore")
$g_bFrmBotMinimized = False
Local $botPosX = ($g_bAndroidEmbedded = False ? $g_iFrmBotPosX : $g_iFrmBotDockedPosX)
Local $botPosY = ($g_bAndroidEmbedded = False ? $g_iFrmBotPosY : $g_iFrmBotDockedPosY)
Local $aPos = [$botPosX, $botPosY]
;SetDebugLog("Restore bot window to " & $botPosX & ", " & $botPosY & ", caller: " & $sCaller, Default, True)
Local $iExStyle = _WinAPI_GetWindowLong($g_hFrmBot, $GWL_EXSTYLE)
If BitAND($iExStyle, $WS_EX_TOOLWINDOW) Then
WinMove2($g_hFrmBot, "", -1, -1, -1, -1, 0, $SWP_HIDEWINDOW, False)
_WinAPI_SetWindowLong($g_hFrmBot, $GWL_EXSTYLE, BitAND($iExStyle, BitNOT($WS_EX_TOOLWINDOW)))
EndIf
If _WinAPI_IsIconic($g_hFrmBot) Then WinSetState($g_hFrmBot, "", @SW_RESTORE)
If $g_bAndroidAdbScreencap = False And $g_bRunState = True And $g_bBotPaused = False And _WinAPI_IsIconic($g_hAndroidWindow) Then WinSetState($g_hAndroidWindow, "", @SW_RESTORE)
WinMove2($g_hFrmBot, "", $botPosX, $botPosY, -1, -1, $HWND_TOP, $SWP_SHOWWINDOW)
_WinAPI_SetActiveWindow($g_hFrmBot)
_WinAPI_SetFocus($g_hFrmBot)
If _CheckWindowVisibility($g_hFrmBot, $aPos) Then
SetDebugLog("Bot Window '" & $g_sAndroidTitle & "' not visible, moving to position: " & $aPos[0] & ", " & $aPos[1])
WinMove2($g_hFrmBot, "", $aPos[0], $aPos[1])
EndIf
WinSetTrans($g_hFrmBot, "", 255) ; is set to 1 when "Hide when minimized" is enabled after some time, so restore it
;ReleaseMutex($hMutex)
Return True
EndFunc ;==>BotMinimizeRestore
Func BotMinimize($sCaller, $iForceUpdatingWhenMinimized = False, $iStayMinimizedMillis = 0)
Return BotMinimizeRestore(True, $sCaller, $iForceUpdatingWhenMinimized, $iStayMinimizedMillis)
EndFunc ;==>BotMinimize
Func BotRestore($sCaller)
Return BotMinimizeRestore(False, $sCaller)
EndFunc ;==>BotRestore
Func BotCloseRequest()
If $g_iBotAction = $eBotClose Then
; already requested to close, but user is impatient, so close now
BotClose()
Else
SetLog("Closing " & $g_sBotTitle & ", please wait ...")
EndIf
$g_bRunState = False
$g_bBotPaused = False
$g_iBotAction = $eBotClose
EndFunc ;==>BotCloseRequest
Func AndroidEmbedArrangeActive()
Return False
EndFunc ;==>AndroidEmbedArrangeActive
Func CheckBotShrinkExpandButton()
Return False
EndFunc ;==>CheckBotShrinkExpandButton
Func AndroidEmbedCheck($p1 = False, $p2 = Default, $iAction = Default)
Return False
EndFunc ;==>AndroidEmbedCheck
Func BotWindowCheck()
Return True
EndFunc ;==>BotWindowCheck
Func CheckBotZOrder()
EndFunc ;==>CheckBotZOrder
Func BotShrinkExpandToggleExecute()
EndFunc ;==>BotShrinkExpandToggleExecute
Func updateBtnEmbed()
EndFunc ;==>updateBtnEmbed
Func AndroidEmbed($bEmbed = True)
EndFunc ;==>AndroidEmbed
Func WinGetAndroidHandle()
Return 0
EndFunc ;==>WinGetAndroidHandle
Func GetAndroidPid()
EndFunc ;==>GetAndroidPid
Func _CaptureDispose()
EndFunc ;==>_CaptureDispose
Func SplashStep($s, $a = 0)
EndFunc ;==>SplashStep
Func SuspendAndroid($bSuspend = True)
Return False
EndFunc ;==>SuspendAndroid
; Called from _Sleep() to avoid locked window move state, double minimize calls etc
Func CheckBotRequests()
CheckBotZOrder() ; check Z Order of Windows is ok
If $g_bBotMoveRequested = True Then
$g_bBotMoveRequested = False
_WinAPI_PostMessage($g_hFrmBot, $WM_SYSCOMMAND, 0xF012, 0) ; SC_DRAGMOVE = 0xF012
Else
If $g_bBotShrinkExpandToggleRequested Then BotShrinkExpandToggleExecute()
EndIf
EndFunc ;==>CheckBotRequests
Func SetCriticalMessageProcessing($bCritical = Default)
Return False
EndFunc ;==>SetCriticalMessageProcessing
Func SetupProfileFolder()
$g_sProfileConfigPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\config.ini"
$g_sProfileClanGamesPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\ClanGames_config.ini" ; Team__AiO__MOD
$g_sProfileBuildingStatsPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\stats_buildings.ini"
$g_sProfileBuildingPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\building.ini"
$g_sProfileLogsPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\Logs\"
$g_sProfileLootsPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\Loots\"
$g_sProfileTempPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\Temp\"
$g_sProfileTempDebugPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & "\Temp\Debug\"
$g_sProfileDonateCapturePath = $g_sProfilePath & "\" & $g_sProfileCurrentName & '\Donate\'
$g_sProfileDonateCaptureWhitelistPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & '\Donate\White List\'
$g_sProfileDonateCaptureBlacklistPath = $g_sProfilePath & "\" & $g_sProfileCurrentName & '\Donate\Black List\'
EndFunc ;==>SetupProfileFolder
; Open URL in default browser using ShellExecute
; URL is retrieved from label text or an existing ToolTip Control
Func OpenURL_Label($LabelCtrlID)
Local $url = GUICtrlRead($LabelCtrlID)
If IsString($LabelCtrlID) Then $url = $LabelCtrlID
If StringInStr($url, "http") <> 1 Then
$url = _GUIToolTip_GetText($g_hToolTip, 0, GUICtrlGetHandle($LabelCtrlID))
EndIf
If StringInStr($url, "http") = 1 Then
SetDebugLog("Open URL: " & $url)
ShellExecute($url) ;open web site when clicking label
Else
SetDebugLog("Cannot open URL for Control ID " & $LabelCtrlID, $COLOR_ERROR)
EndIf
EndFunc ;==>OpenURL_Label
Func _GUICtrlStatusBar_SetTextEx($hWnd, $sText = "", $iPart = 0, $iUFlag = 0)
If $hWnd Then _GUICtrlStatusBar_SetText($hWnd, $sText, $iPart, $iUFlag)
EndFunc ;==>_GUICtrlStatusBar_SetTextEx
Func GUIEvents()
;@GUI_WinHandle
;Local $wasCritical = SetCriticalMessageProcessing(True)
Local $wasAllowed = $g_bTogglePauseAllowed
$g_bTogglePauseAllowed = False
Local $GUI_CtrlId = @GUI_CtrlId
SetDebugLog("GUIEvents: " & $GUI_CtrlId, Default, True)
If $g_bFrmBotMinimized And $GUI_CtrlId = $GUI_EVENT_MINIMIZE Then
; restore
If $g_iDebugWindowMessages Then SetDebugLog("$GUI_EVENT_MINIMIZE changed to $GUI_EVENT_RESTORE", Default, True)
$GUI_CtrlId = $GUI_EVENT_RESTORE
EndIf
Switch $GUI_CtrlId
Case $GUI_EVENT_CLOSE
If $g_iDebugWindowMessages Then SetDebugLog("$GUI_EVENT_CLOSE", Default, True)
BotCloseRequest()
Case $GUI_EVENT_MINIMIZE
If $g_iDebugWindowMessages Then SetDebugLog("$GUI_EVENT_MINIMIZE", Default, True)
BotMinimize("GUIEvents")
;Return 0
Case $GUI_EVENT_RESTORE
If $g_iDebugWindowMessages Then SetDebugLog("$GUI_EVENT_RESTORE", Default, True)
BotRestore("GUIEvents")
Case Else
If $g_iDebugWindowMessages Then SetDebugLog("$GUI_EVENT: " & @GUI_CtrlId, Default, True)
EndSwitch
$g_bTogglePauseAllowed = $wasAllowed
EndFunc ;==>GUIEvents
Func GUIControl_WM_CLOSE($hWind, $iMsg, $wParam, $lParam)
;Local $wasCritical = SetCriticalMessageProcessing(True)
If $g_iDebugWindowMessages > 0 Then SetDebugLog("GUIControl_WM_CLOSE: $hWind=" & $hWind & ",$iMsg=" & $iMsg & ",$wParam=" & $wParam & ",$lParam=" & $lParam, Default, True)
If $hWind = $g_hFrmBot Then
BotCloseRequest()
EndIf
EndFunc ;==>GUIControl_WM_CLOSE
Func GUIControl_WM_COMMAND($hWind, $iMsg, $wParam, $lParam)
If $g_bGUIControlDisabled = True Then Return $GUI_RUNDEFMSG
Local $wasAllowed = $g_bTogglePauseAllowed
$g_bTogglePauseAllowed = False
If $g_iDebugWindowMessages > 1 Then SetDebugLog("GUIControl_WM_COMMAND: $hWind=" & $hWind & ",$iMsg=" & $iMsg & ",$wParam=" & $wParam & ",$lParam=" & $lParam, Default, True)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)
Local $hCtrl = $lParam
Switch $nID
Case $g_hLblBotMinimize
BotMinimizeRequest()
Case $GUI_EVENT_CLOSE, $g_hLblBotClose
; Clean up resources
BotCloseRequest()
Case $g_hFrmBot_URL_PIC, $g_hFrmBot_URL_PIC2
;OpenURL_Label($g_hLblMyBotURL)
OpenURL_Label("https://mybot.run/forums")
Case $g_hLblDonate
; Donate URL is not in text nor tooltip
ShellExecute("https://mybot.run/forums/index.php?/donate/make-donation/")
Case $g_hBtnStart, $g_hTblStart
btnStart()
Case $g_hBtnStop, $g_hTblStop
btnStop()
Case $g_hBtnPause, $g_hTblPause
btnPause()
Case $g_hBtnResume, $g_hTblResume
btnResume()
Case $g_hBtnHide
btnHide()
Case $g_hBtnMakeScreenshot, $g_hTblMakeScreenshot
btnMakeScreenshot()
Case $g_hPicArrowLeft
$g_iCurrentReport -= 1
If $g_iCurrentReport < $g_iVillageReport Then $g_iCurrentReport = $g_iBBReport
btnVillageStat()
Case $g_hPicArrowRight
$g_iCurrentReport += 1
If $g_iCurrentReport > $g_iBBReport Then $g_iCurrentReport = $g_iVillageReport
btnVillageStat()
; debug checkboxes and buttons
EndSwitch
#cs mini
If $lParam = $g_hCmbGUILanguage Then
If $nNotifyCode = $CBN_SELCHANGE Then cmbLanguage()
EndIf
#ce
$g_bTogglePauseAllowed = $wasAllowed
Return $GUI_RUNDEFMSG
EndFunc ;==>GUIControl_WM_COMMAND
Func GUIControl_WM_MOVE($hWind, $iMsg, $wParam, $lParam)
;If $g_bGUIControlDisabled = True Then Return $GUI_RUNDEFMSG
If $g_bBotShrinkExpandToggleRequested Then Return $GUI_RUNDEFMSG ; bot shrinking is requested or active
Local $wasCritical = SetCriticalMessageProcessing(True)
Local $wasAllowed = $g_bTogglePauseAllowed
$g_bTogglePauseAllowed = False
If $g_iDebugWindowMessages Then SetDebugLog("GUIControl_WM_MOVE: $hWind=" & $hWind & ",$iMsg=" & $iMsg & ",$wParam=" & $wParam & ",$lParam=" & $lParam, Default, True)
If $hWind = $g_hFrmBot Then
If $g_bUpdatingWhenMinimized And BotWindowCheck() = False And _WinAPI_IsIconic($g_hFrmBot) Then
; ensure bot is not really minimized (e.g. when you minimize all windows)
BotMinimize("GUIControl_WM_MOVE")
$g_bTogglePauseAllowed = $wasAllowed
SetCriticalMessageProcessing($wasCritical)
Return $GUI_RUNDEFMSG
EndIf
; update bot pos variables
Local $g_iFrmBotPos = WinGetPos($g_hFrmBot)
If $g_bAndroidEmbedded = False Then
$g_iFrmBotPosX = ($g_iFrmBotPos[0] > -30000 ? $g_iFrmBotPos[0] : $g_iFrmBotPosX)
$g_iFrmBotPosY = ($g_iFrmBotPos[1] > -30000 ? $g_iFrmBotPos[1] : $g_iFrmBotPosY)
Else
$g_iFrmBotDockedPosX = ($g_iFrmBotPos[0] > -30000 ? $g_iFrmBotPos[0] : $g_iFrmBotDockedPosX)
$g_iFrmBotDockedPosY = ($g_iFrmBotPos[1] > -30000 ? $g_iFrmBotPos[1] : $g_iFrmBotDockedPosY)
EndIf
; required for screen change
If $g_bAndroidEmbedded And AndroidEmbedArrangeActive() = False Then
CheckBotShrinkExpandButton()
Local $iAction = AndroidEmbedCheck(True)
If $iAction > 0 Then
; reposition docked android
AndroidEmbedCheck(False, Default, $iAction)
; redraw bot also
;temp;_WinAPI_RedrawWindow($g_hFrmBotEx, 0, 0, $RDW_INVALIDATE)
;temp;_WinAPI_RedrawWindow($frmBotBottom, 0, 0, $RDW_INVALIDATE)
EndIf
If $g_iDebugWindowMessages Then
Local $a = $g_iFrmBotPos
SetDebugLog("Bot Position: " & $a[0] & "," & $a[1] & " " & $a[2] & "x" & $a[3])
$a = WinGetPos($g_hAndroidWindow)
SetDebugLog("Android Position: " & $a[0] & "," & $a[1] & " " & $a[2] & "x" & $a[3])
If $g_hFrmBotEmbeddedMouse <> 0 Then
$a = WinGetPos($g_hFrmBotEmbeddedMouse)
SetDebugLog("Mouse Window Position: " & $a[0] & "," & $a[1] & " " & $a[2] & "x" & $a[3])
EndIf
EndIf
EndIf
EndIf
$g_bTogglePauseAllowed = $wasAllowed
SetCriticalMessageProcessing($wasCritical)
Return $GUI_RUNDEFMSG
EndFunc ;==>GUIControl_WM_MOVE
Func SetTime($bForceUpdate = False)
If $g_hTimerSinceStarted = 0 Then Return ; GIGO, no setTime when timer hasn't started yet
Local $day = 0, $hour = 0, $min = 0, $sec = 0
#cs mini
If GUICtrlRead($g_hGUI_STATS_TAB, 1) = $g_hGUI_STATS_TAB_ITEM2 Or $bForceUpdate = True Then
_TicksToDay(Int(__TimerDiff($g_hTimerSinceStarted) + $g_iTimePassed), $day, $hour, $min, $sec)
GUICtrlSetData($g_hLblResultRuntime, $day > 0 ? StringFormat("%2u Day(s) %02i:%02i:%02i", $day, $hour, $min, $sec) : StringFormat("%02i:%02i:%02i", $hour, $min, $sec))
EndIf
#ce
If GUICtrlGetState($g_hLblResultGoldNow) <> $GUI_ENABLE + $GUI_SHOW Or $bForceUpdate = True Then
_TicksToTime(Int(__TimerDiff($g_hTimerSinceStarted) + $g_iTimePassed), $hour, $min, $sec)
GUICtrlSetData($g_hLblResultRuntimeNow, StringFormat("%02i:%02i:%02i", $hour, $min, $sec))
EndIf
EndFunc ;==>SetTime
Func TogglePause()
TogglePauseImpl("Mini")
EndFunc ;==>TogglePause
Func btnStart()
;$g_iBotAction = $eBotStart
BotStart()
EndFunc ;==>btnStart
Func btnStop()
;$g_iBotAction = $eBotStop
BotStop()
EndFunc ;==>btnStop
Func btnPause()
TogglePause()
EndFunc ;==>btnPause
Func btnResume()
TogglePause()
EndFunc ;==>btnResume
; Enable/Disable GUI while botting - Team AiO MOD++
Func btnEnableGUI()
EndFunc ;==>btnEnableGUI
Func btnDisableGUI()
EndFunc ;==>btnDisableGUI
; Enable/Disable GUI while botting - Team AiO MOD++
Func btnVillageStat($source = "")
If $g_iFirstRun = 0 And $g_bRunState And Not $g_bBotPaused Then SetTime(True)
If $g_iCurrentReport = $g_iVillageHourlyReport Then
;HIDE Village Report Values
GUICtrlSetState($g_hLblResultGoldNow, $GUI_ENABLE + $GUI_HIDE)
GUICtrlSetState($g_hLblResultElixirNow, $GUI_ENABLE + $GUI_HIDE)
GUICtrlSetState($g_hLblResultDENow, $GUI_ENABLE + $GUI_HIDE)
GUICtrlSetState($g_hLblResultTrophyNow, $GUI_ENABLE + $GUI_HIDE)
GUICtrlSetState($g_hLblResultBuilderNow, $GUI_ENABLE + $GUI_HIDE)
GUICtrlSetState($g_hLblResultGemNow, $GUI_ENABLE + $GUI_HIDE)
If $g_iFirstRun = 1 Then
GUICtrlSetState($g_hPicResultDETemp, $GUI_ENABLE + $GUI_SHOW)
Else
GUICtrlSetState($g_hPicResultDENow, $GUI_ENABLE + $GUI_SHOW)
EndIf
;HIDE BB Report Values
GUICtrlSetState($g_hLblBBResultGoldNow, $GUI_ENABLE + $GUI_HIDE)
GUICtrlSetState($g_hLblBBResultElixirNow, $GUI_ENABLE + $GUI_HIDE)