AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

break loop ifwinactive

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
TOTAL



Joined: 26 Sep 2007
Posts: 44

PostPosted: Mon Mar 31, 2008 4:23 am    Post subject: break loop ifwinactive Reply with quote

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.
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 559
Location: MN, USA

PostPosted: Mon Mar 31, 2008 4:49 am    Post subject: Reply with quote

You want IfWinActive. #IfWinActive is only for hotkeys.
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Mon Mar 31, 2008 5:18 am    Post subject: Reply with quote

Thanks!!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group