GUI freezes if being moved while WinWaitNotActive is run
Posted: 29 Nov 2017, 04:24
I stumbled upon this earlier tonight and whipped up the simplest code to demonstrate it:
Interestingly, the hotkey to kill the script still works, so it's not the process that's frozen, just the GUI. Along with the GUI being frozen, the mouse pointer gets locked out of entering the Windows taskbar area and from clicking on other apps. Keyboard commands (like Alt+Tab) work, though. Also, if I change the command to WinWaitActive, the window movement will noticeably stutter, but won't freeze the GUI. The same thing happens if I leave it as WinWaitNotActive and change the window title to wait for to something else (i.e. if the title match fails). Finally, the total freezing also happens with While WinActive("Test") and While WinExist("Test").
I ran into this because I have a script that sets a timer which, when it goes off, checks whether the GUI window is active, and I happened to be moving the window when the timer went off.
I should add that this is with v1.1.26.01 and I'm on Windows 10 x64.
Edit: If anyone stumbles upon this, a workaround that I've found is to simply precede the WinWaitNotActive line with If !(GetKeyState("LButton", "P")), so that it doesn't process it if the user is pressing the left mouse button, since he might be dragging the window around.
Code: Select all
Gui, New, -MinimizeBox, Test
Gui, Add, Text, x0 y10 w300 h50 Center, While moving this window around by the title bar, press Q.`nWhen it freezes, press Esc to exit the script.
Gui, Show, h50 w300, Test
Return
Esc::ExitApp
q::WinWaitNotActive, Test
I ran into this because I have a script that sets a timer which, when it goes off, checks whether the GUI window is active, and I happened to be moving the window when the timer went off.
I should add that this is with v1.1.26.01 and I'm on Windows 10 x64.
Edit: If anyone stumbles upon this, a workaround that I've found is to simply precede the WinWaitNotActive line with If !(GetKeyState("LButton", "P")), so that it doesn't process it if the user is pressing the left mouse button, since he might be dragging the window around.