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 

Global IfWinActive

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Harmless
Guest





PostPosted: Thu Jul 15, 2004 10:39 am    Post subject: Global IfWinActive Reply with quote

For application-specific scripts, it would be nice to have a global setting which makes all Hotkeys only work if the specified window is currently active.

As far as I can tell, the only way to do this at present is to check IfWinActive / IfWinNotActive in each hotkey routine. For scripts with a lot of hotkeys, this accounts for substantial bulk in the source script.

By the way, love the software!
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Jul 15, 2004 11:47 am    Post subject: Reply with quote

There's another easy way to do it.
Code:
;At the top of the script:
SetTimer, SuspendHotkeys, 50
... whatever else
return

SuspendHotkeys:
IfWinActive, ahk_class Notepad
     Suspend, Off
else
     Suspend, On
return


It uses the ahk_class method to more easily detect which type of app is active (which would be useful if the title varies). In addition, you could make it more selective by using Suspend, Permit as the first line of any hotkey you want to be exempt from the rule. You can also use the Hotkey command to disable/enable only a specific set of hotkeys.
Back to top
View user's profile Send private message Send e-mail
Harmless
Guest





PostPosted: Thu Jul 15, 2004 12:14 pm    Post subject: Reply with quote

Thanks Chris.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List 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