 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Harmless Guest
|
Posted: Thu Jul 15, 2004 10:39 am Post subject: Global IfWinActive |
|
|
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
|
Posted: Thu Jul 15, 2004 11:47 am Post subject: |
|
|
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 |
|
 |
Harmless Guest
|
Posted: Thu Jul 15, 2004 12:14 pm Post subject: |
|
|
| Thanks Chris. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|