Explorar el Código

restore previous window after bot done

chestercs hace 2 años
padre
commit
cc0370ec85
Se han modificado 1 ficheros con 22 adiciones y 8 borrados
  1. 22 8
      klanhaboru_main.au3

+ 22 - 8
klanhaboru_main.au3

@@ -1,5 +1,5 @@
 #include <Date.au3>
-;; Klanhaboru fun
+ConsoleWrite(";; Klanhaboru fun by ChesTeRcs@2023 ;;" & @CRLF)
 
 #Region === Configurations
    AutoItSetOption("SendKeyDelay",      1)
@@ -13,7 +13,7 @@
    Global $villageId = 					IniRead(@ScriptDir & "/config.ini", "Options", "villageId", 	"1")     	; get it from game url
    Global $scavengeMode = 				IniRead(@ScriptDir & "/config.ini", "Options", "scavengeMode", 	"2")  		; Mode 0-3 (0-Lusta gyûjtögetõk, 1-Szerény gyûjtögetõk, 2-Okos gyûjtögetõk, 3-Kiváló gyûjtögetõk)
    Global $traytip = 					IniRead(@ScriptDir & "/config.ini", "Options", "trayTip", 		true)
-   Global $debug = 						IniRead(@ScriptDir & "/config.ini", "Options", "debug", 		true)
+   Global $debug = 						IniRead(@ScriptDir & "/config.ini", "Options", "debug", 		false)
    Global $gyujtogetesEventTimer = 		eventStart(0)   ; delay task after bot started with seconds (default: 0)
    Global $trainUnitsEventTimer = 		eventStart(0)   ; delay task after bot started with seconds (default: 0)
    Global $trainLovassagEventTimer = 	eventStart(0) 	; delay task after bot started with seconds (default: 0)
@@ -24,23 +24,25 @@
    Global $diamondGatheringEventTimer = eventStart(0)   ; delay task after bot started with seconds (default: 0)
 
    Global $pageLoadTime = 				0 				; inMs  ; look at navigateToUrl last WinWaitActive
-   Global $sleepTimesInEndOfTasks = 	3000			; inMs
+   Global $sleepTimesInEndOfTasks = 	0				; inMs
+   Global $toggleRestoreLastWindow = 	false           ; dont change
 #EndRegion
 
 
+
 While loopEnd()
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Gyûjtögetés
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  sendAll, mode,		landzsas, kardforgato, bardos, ijasz, 		konnyulovas, lovasijasz, nehezlovas, lovag 			(-1 meant to send all unit button)
    $gyujtogetesEventTimer = 	gyujtogetes(false, 3, 	0, 0, 0, 0,		-1, -1, -1, 0,					 	$gyujtogetesEventTimer)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Train Units
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  landzsas, kardforgato, bardos, ijasz  (can be -1 what is meant to all unit button)
-   $trainUnitsEventTimer = 		trainUnits(				0, 1, 0, 0, 						 			3600, 	$trainUnitsEventTimer)
+   $trainUnitsEventTimer = 		trainUnits(				0, 0, 0, 0, 						 			7200, 	$trainUnitsEventTimer)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Train Lovassag
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  kem, konnyulovas, lovasijasz, nehezlovas  (can be -1 what is meant to all unit button)
    $trainLovassagEventTimer = 	trainLovassag(			0, 0, 0, 0, 						 			3600, 	$trainLovassagEventTimer)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Train Machinery
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  kos, katapult  (can be -1 what is meant to all unit button)
-   $trainMachinesEventTimer = 	trainMachines(			0, 1, 								 			3600,	$trainMachinesEventTimer)
+   $trainMachinesEventTimer = 	trainMachines(			0, 0, 								 			3600,	$trainMachinesEventTimer)
 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Építés
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
@@ -52,7 +54,7 @@ While loopEnd()
 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Send Attack
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  $x, $y,	 $landzsas, $kardforgato, $bardos, $ijasz, 	$kem, $konnyulovas, $lovasijasz, $nehezlovas, 	$kos, $katapult, 	$lovag, $nemes, $eventTimer, $repeatTimer
-   $sendAttackEventTimer = 		sendAttack(	490, 562,    0, 0, 0, 0,   		1, 0, 0, 0,    0, 0, 0, 0, 	3600,	$sendAttackEventTimer)  ; 10800 - 3h
+   $sendAttackEventTimer = 		sendAttack(490, 562,    0, 0, 0, 0,   		1, 0, 0, 0,    0, 0, 0, 0, 	3600,	$sendAttackEventTimer)  ; 10800 - 3h
 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;  Diamon Gathering event
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -60,10 +62,16 @@ While loopEnd()
 WEnd
 
 
+
 #Region === Functions
 Func loopEnd()
    TrayTipGG("")
    Sleep(1000)
+   If ($debug == true) Then ConsoleWrite("should alt tab: " & $toggleRestoreLastWindow & @CRLF)
+   If ($toggleRestoreLastWindow == true) Then
+	  Send("!{TAB}")
+	  $toggleRestoreLastWindow = false
+   EndIf
    return true
 EndFunc
 
@@ -257,14 +265,20 @@ EndFunc
 
 #Region === Helper Functions
 Func openNewTab()
+   $hWnd = WinGetHandle("[active]")
+   $hWndBrowser = WinGetHandle($browser)
+   if ($hWnd <> $hWndBrowser) Then $toggleRestoreLastWindow = true
    WinActivate($browser)
-   Sleep(100)
+   Sleep(10)
    Send("^t")
-   Sleep(100)
+   Sleep(10)
 EndFunc
 
 Func closeTab()
+   WinActivate($browser)
+   Sleep(10)
    Send("^w")
+   Sleep(10)
 EndFunc
 
 Func getGameUrl($screen, $mode = "")