TOTAL
Joined: 26 Sep 2007 Posts: 44
|
Posted: Mon Mar 31, 2008 4:23 am Post subject: break loop ifwinactive |
|
|
Hi
In a program there are two windows: window one and window two.
In window one I want capslock to trigger a simple loop, until capslock released.
And it works fine. But occasionally the subroutine leads to a change of window - from window one to window two, which is a natural consequence of looped commands.
this is when the loop should break. But it doesn't.
AHK properly recognizes the windows before the loop gets triggered. I know it because only in window one capslock takes effect. But when the window changes, or I do it, the loop continues. And it is not supposed to.
I have tried both
#ifWiNActive window one, continue (as in the code)
and
#ifWiNNotActive window one, break (which would be even better)
but to no avail. I suspect it is a simple syntax issue, but I can't find any hint in the Help.
| Code: |
#ifWiNActive window one,
~CapsLock::
Loop
{
GetKeyState, state, CapsLock, T ; D if CapsLock is ON or U otherwise.
if state = U ; The key has been released, so break out of the loop.
break
MouseClick, left, 105, 558
SEND, {ENTER}
Sleep, 2000
#ifWiNActive window one, continue
; ... insert here any other actions you want repeated.
}
return
|
Pls help. |
|