From 6a867b6dfe6e02dcbe907d83dde9245fd471a8dd Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 22 Aug 2022 21:08:47 +0300 Subject: [PATCH] Wait for windows because SetWinDelay -1 --- night.ahk | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/night.ahk b/night.ahk index 901fd7e..51c3e76 100644 --- a/night.ahk +++ b/night.ahk @@ -46,6 +46,17 @@ WaitWindowExist(WinTitle, SleepAmount, Timeout) { } } +WaitWindowActive(WinTitle, SleepAmount, Timeout) { + Start := A_TickCount + while (!WinActive(WinTitle)) { + Sleep % SleepAmount + if (A_TickCount - Start > Timeout) { + return false + } + } + return true +} + WaitWindowNotActive(WinTitle, SleepAmount, Timeout) { Start := A_TickCount while (WinActive(WinTitle)) { @@ -596,6 +607,9 @@ WaitFocusColorizeWindow() { } WinActivate % "ahk_id " Hwnd + if (!WaitWindowActive("ahk_id " Hwnd, 5, 1000)) { + return + } WinGetPos, , , Width, Height, % "ahk_id " Hwnd if (!Width) { @@ -915,7 +929,12 @@ $XButton1:: if (!(Hwnd := WinExist(AppProjectWindowTitle))) { return } + WinActivate % "ahk_id " Hwnd + if (!WaitWindowActive("ahk_id " Hwnd, 5, 1000)) { + return + } + SendEvent % MacroKeys["Show Lower Zone MixConsole Page " MixConsolePage] MacroKeys["Edit - Open/Close Editor"] return @@ -923,7 +942,12 @@ $XButton2:: if (!(Hwnd := WinExist(AppProjectWindowTitle))) { return } + WinActivate % "ahk_id " Hwnd + if (!WaitWindowActive("ahk_id " Hwnd, 5, 1000)) { + return + } + SendEvent % MacroKeys["Show Lower Zone MixConsole Page " MixConsolePage] return