AutoHotkey Tip of the Week: IfWinActive Versus #IfWinActive—August 12, 2019

Tip: Isolate Your Hotkeys and Hotstrings to the Appropriate Window

Light Bulb!As beginners, we tend to create universal Hotkeys and Hotstrings which work everywhere. This usually works out in our early scripts, but, eventually, we discover that our key combinations either interfere with particular programs or we begin to run out of easy-to-remember Hotkeys and Hotstrings. To resolve this issue, limit your Hotkeys and Hotstring to working only for those programs where you need them.

hotkeycover200You can create context-sensitive Hotkeys and Hotstring with either the IfWinActive function or command or the #IfWinActive directive. Which you use depends upon what you need to do. The IfWinActive command allows greater flexibility for any set of conditions, while the #IfWinActive directive only works for Hotkeys and Hotstrings.

For more information, see “Chapter Two: Block Windows Shortcuts with AutoHotkey” and “Chapter Three: AutoHotkey #Directives for Context-Sensitive Hotkeys—#IfWinActive” of the book AutoHotkey Hotkey Tips, Tricks, and Techniques, (Chapter Three clears up the confusion between AutoHotkey’s IfWinActive command and the #IfWinActive directive.)

Click the Follow button at the top of the sidebar on the right of this page for e-mail notification of new blogs. (If you’re reading this on a tablet or your phone, then you must scroll all the way to the end of the blog—pass any comments—to find the Follow button.)

jack

This post was proofread by Grammarly
(Any other mistakes are all mine.)

(Full disclosure: If you sign up for a free Grammarly account, I get 20¢. I use the spelling/grammar checking service all the time, but, then again, I write a lot more than most people. I recommend Grammarly because it works and it’s free.)

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s