Take Advantage of Hotstring Precedence to Deactivate Unwanted Hotstrings Firing
Sometimes AutoHotkey Hotstrings fire at the wrong time. For example, whenever I put the word AutoHotkey into a document I prefer the full word rather than an abbreviation (AHK). I use “ahk” as the Hotstring—replacing it with “AutoHotkey” in almost all cases.
However, when I started adding the same extension to my scripts, I would get “IPFind.AutoHotkey” rather than the “IPFind.ahk” that I needed. This was exacerbated by the fact that the preceding dot ( . ) caused a Hotstring reset making some of the usual fixes unavailable. I needed to disable “.ahk” as a Hotstring.
The two requirements for neutralizing an errant Hotstring include:
- The new Hotstring must appear in the script before the primary Hotstring. The first form of a Hotstring found in the script takes precedence over any following Hotstrings using the same trigger.
Note: Hotstring precedence only applies to Hotstrings loaded from the same script. The most recently loaded identical Hotstrings from another script takes precedence over any previously activated Hotstrings.
- Reset the Hotstring trigger without any replacement.
The following set of Hotstrings disable auto-replacement whenever preceding the activation term “ahk” with a dot ( . ) while continuing to replace all other lower-case forms of “ahk” with “AutoHotkey”:
When activated, the
B0 option prevents backspacing, the
C option ensures an all lowercase trigger, and the
? option causes immediate execution. Effectively, the activation makes nothing happen—except resetting the Hotstring trigger. AutoHotkey recognizes “.ahk” and does not replace it. Any other form of all lowercase “ahk” triggers “AutoHotkey” as its replacement.
You’ll find other, more complex methods for dealing with special Hotstring situations but sometimes all you want a Hotstring to do is nothing.
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.)
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.)
Find my AutoHotkey books at ComputorEdge E-Books!
Find quick-start AutoHotkey classes at “Robotic Desktop Automation with AutoHotkey“!