From b49136debac1a8a2babceca033c2c3286ed06c03 Mon Sep 17 00:00:00 2001 From: Detroit Date: Mon, 4 Nov 2019 14:37:56 +0100 Subject: [PATCH] Fixed script didn't enter correct info when some accounts were unactive. --- Scenarios/ConnectPlayersOnServer.ahk | 15 ++++++++++----- Scenarios/LoginAccounts.ahk | 13 +++++++++---- Scenarios/Out/MergedScenarios.ahk | 28 +++++++++++++++++++--------- settings_default.ini | 2 +- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/Scenarios/ConnectPlayersOnServer.ahk b/Scenarios/ConnectPlayersOnServer.ahk index 27ea004..468ab08 100644 --- a/Scenarios/ConnectPlayersOnServer.ahk +++ b/Scenarios/ConnectPlayersOnServer.ahk @@ -6,18 +6,22 @@ Main: API.GuiUpdateProgressBar(0) section := A_ScreenWidth . "x" . A_ScreenHeight - Loop, % API.GetNbWindows() { + i := 1 + Loop, % API.GetTotalAccounts() { + ;Skip unactive accounts + If !ArrayAccounts[A_Index].IsActive + Continue ;Get value for server slot inputX := Scenario.GetValueFromIni(section, "x" ArrayAccounts[A_Index].ServerSlot) inputY := Scenario.GetValueFromIni(section, "y" ArrayAccounts[A_Index].ServerSlot) - If (inputX = -1 || inputY = -1) + If (!inputX || !inputY) { API.LogWrite("Couldn't load account input position from INI, stopping current scenario.", 2) return } - window := API.GetWindow(A_Index) + window := API.GetWindow(i) window.Activate() window.WaitActive() @@ -43,10 +47,11 @@ Main: ;Connect player Sleep 50 * Settings.Speed Click, 2 - API.GuiUpdateProgressBar(A_Index, API.GetNbWindows()) + API.GuiUpdateProgressBar(i, API.GetNbWindows()) + i++ Sleep 500 } - API.LogWrite("Successfully connected " API.GetNbWindows() " characters.") + API.LogWrite("Successfully connected " i " characters.") API.GuiUpdateProgressBar(100) return \ No newline at end of file diff --git a/Scenarios/LoginAccounts.ahk b/Scenarios/LoginAccounts.ahk index b457aaa..3f4e493 100644 --- a/Scenarios/LoginAccounts.ahk +++ b/Scenarios/LoginAccounts.ahk @@ -10,15 +10,19 @@ Main: section := A_ScreenWidth . "x" . A_ScreenHeight inputX := Scenario.GetValueFromIni(section, "x") inputY := Scenario.GetValueFromIni(section, "y") - If (inputX = -1 || inputY = -1) + If (!inputX || !inputY) { API.LogWrite("Couldn't load account input position from INI, stopping current scenario.", 2) return } - Loop, % API.GetNbWindows() { + i := 1 + Loop, % API.GetTotalAccounts() { + ;Skip unactive accounts + If !ArrayAccounts[A_Index].IsActive + Continue If (Settings.WaitForAnkamaShield = True) MsgBox, % Translate("UnlockShield", API.GetUsername(A_Index)) - window := API.GetWindow(A_Index) + window := API.GetWindow(i) window.Activate() window.WaitActive() window.Maximize() @@ -35,7 +39,8 @@ Main: Send, {Tab} Sleep, 50 * Settings.Speed Send {Enter} - API.GuiUpdateProgressBar(A_Index, API.GetNbWindows()) + API.GuiUpdateProgressBar(i, API.GetNbWindows()) + i++ SleepHandler(0) ;handle sleep based on speed settings (parameter is for added sleep) } API.GuiUpdateProgressBar(100) diff --git a/Scenarios/Out/MergedScenarios.ahk b/Scenarios/Out/MergedScenarios.ahk index d8f3fd7..3b21449 100644 --- a/Scenarios/Out/MergedScenarios.ahk +++ b/Scenarios/Out/MergedScenarios.ahk @@ -39,18 +39,22 @@ ConnectPlayersOnServer: API.GuiUpdateProgressBar(0) section := A_ScreenWidth . "x" . A_ScreenHeight - Loop, % API.GetNbWindows() { + i := 1 + Loop, % API.GetTotalAccounts() { + ;Skip unactive accounts + If !ArrayAccounts[A_Index].IsActive + Continue ;Get value for server slot inputX := Scenario.GetValueFromIni(section, "x" ArrayAccounts[A_Index].ServerSlot) inputY := Scenario.GetValueFromIni(section, "y" ArrayAccounts[A_Index].ServerSlot) - If (inputX = -1 || inputY = -1) + If (!inputX || !inputY) { API.LogWrite("Couldn't load account input position from INI, stopping current scenario.", 2) return } - window := API.GetWindow(A_Index) + window := API.GetWindow(i) window.Activate() window.WaitActive() @@ -76,11 +80,12 @@ ConnectPlayersOnServer: ;Connect player Sleep 50 * Settings.Speed Click, 2 - API.GuiUpdateProgressBar(A_Index, API.GetNbWindows()) + API.GuiUpdateProgressBar(i, API.GetNbWindows()) + i++ Sleep 500 } - API.LogWrite("Successfully connected " API.GetNbWindows() " characters.") + API.LogWrite("Successfully connected " i " characters.") API.GuiUpdateProgressBar(100) return @@ -133,15 +138,19 @@ LoginAccounts: section := A_ScreenWidth . "x" . A_ScreenHeight inputX := Scenario.GetValueFromIni(section, "x") inputY := Scenario.GetValueFromIni(section, "y") - If (inputX = -1 || inputY = -1) + If (!inputX || !inputY) { API.LogWrite("Couldn't load account input position from INI, stopping current scenario.", 2) return } - Loop, % API.GetNbWindows() { + i := 1 + Loop, % API.GetTotalAccounts() { + ;Skip unactive accounts + If !ArrayAccounts[A_Index].IsActive + Continue If (Settings.WaitForAnkamaShield = True) MsgBox, % Translate("UnlockShield", API.GetUsername(A_Index)) - window := API.GetWindow(A_Index) + window := API.GetWindow(i) window.Activate() window.WaitActive() window.Maximize() @@ -158,7 +167,8 @@ LoginAccounts: Send, {Tab} Sleep, 50 * Settings.Speed Send {Enter} - API.GuiUpdateProgressBar(A_Index, API.GetNbWindows()) + API.GuiUpdateProgressBar(i, API.GetNbWindows()) + i++ SleepHandler(0) ;handle sleep based on speed settings (parameter is for added sleep) } API.GuiUpdateProgressBar(100) diff --git a/settings_default.ini b/settings_default.ini index 1b22b27..702c714 100644 --- a/settings_default.ini +++ b/settings_default.ini @@ -26,4 +26,4 @@ F8=ActivateWindow8 F9=OpenDofusInstances F10=LoginAccounts F11=ConnectPlayersOnServer -F12=ExitApp +F12=CloseDofusInstances