I have a simple autohotkeys macro to test if a window is active. If it's active, I want to do something but then stop until the window becomes inactive and then re-activated again.
The problem is my test for whether the window was previously inactive is not working. Here is my code:
^w::
;hotkey always fires
done = false
SetTimer, CheckPopups, 10000 ; check every 10 seconds for annoying popup
CheckPopups:
if ( WinActive("Volume Spike - Down") )
{
;specific lines only when active window is true
msgbox (%done%)
if (!done) {
msgbox hello
done := true
}
}
IfWinNotActive Volume Spike - Down
{
done = false
msgbox Not
}
Return
When this runs, I get the first message box indicating the state of done (which is false at the beginning). But (!done) does not evaluate to true and the second message box (hello) is not fired. Any idea what is wrong here?