Beginning Hotstring Tricks for Expanding Acronyms (AutoHotkey Tips)

Hotstring Techniques for Expanding Abbreviations Only When You Need Them, Plus How to Sound British…Sort Of

One benefit I’ve discovered when using my InstantHotstring.ahk script includes quickly checking the effects of the various Hotstring options. Without re-editing and reloading an AutoHotkey script, I can test the assorted options and see how they modify the behavior of each Hotstring. This helps me understand how to solve some Hotstring problems.

Beginning AutoHotkey Hotstrings 200pxTip: The Hotstring() function (the engine for this AutoHotkey script) does not completely replace a loaded list of AutoHotkey Hotstrings. You can accomplish a number of things with a Hotstring script which the function does not appear capable of doing (e.g. long replacements). (See the book Beginning AutoHotkey Hotstrings.)

For example, while you can use the Tab character (`t) as part of the activating string in a script, it does not work in the Hotstring() function. Plus, you can only use predefined Label subroutines or functions when activating the X option, while in an AutoHotkey script you can create multi-line Hotstrings to perform any custom action.

Expanding Acronyms—Only When Needed

When writing names or terms with long titles which may reoccur a number of times, we tend to use acronyms in place of the phrase. For example, GUI stands for Graphical User Interface. By using GUI we save time and redundant encounters with the longer group of words by replacing them with a shorter replacement. However, the first time we use an acronym, we should define it.

Note: Nothing annoys me more than finding an acronym used throughout an article without any definition. The writer assumes that everyone knows what they mean. Well, I don’t! I often resort to a Web search to determine what the heck they’re talking about.

In legal documents, all such terms (including lessor and lessee) get defined on the first page. If a person writes numerous documents which use a number of acronyms, a set of Hotstrings which inserts definitions on command could prove useful. You’ll find a couple of different combinations of Hotstring options which make this work.


In the example above, I added four Hotstring options to create an on command acronym expansion. First, the C option ensures it only responds to all capital letters. Second, the * option executes the expansion the instant we press the hyphen (-) key. Third, the no backspace B0 option prevents the removal of the acronym characters. Finally, the omit O option removes the activating hyphen from the results. Note: The replacement text must begin with a space for the proper formatting of the new text.

If I type GUI without the hyphen, it remains unchanged. If I add the hyphen, I get the “GUI (Graphical User Interface)” expansion.

To be fair, I can do the same thing with only two options using a full replacement.


In this case, AutoHotkey does a full replacement the instant I press the hyphen key. Otherwise, this Hotstring offers identical results as the first—although accomplished in a different manner. However, you may find times when a set of options similar to the first example offer the preferred results.

Masquerading as a Brit

The British use the letter Z (Zed) much more sparingly than Americans. Yet, as an American, I always cock my head a little when I see the word organisation in print—although many British find it quite acceptable to use Z. If I wanted to masquerade as a Brit, I could implement some Hotstring options to prevent me from using the letter Z in those ambiguous words.


By instantly converting any “z” following an “i” into an “s”, all such words containing a “z” get homogenised. The combination “iz” turns into “is” by immediately (*) activating the Hotstring inside any word (?) using the no backspace option (B0) and the omit EndChar option (O) to remove only the  “z”, then replacing it with the “s” character.

Admittedly, the rules are far more controversial than I care to deal with. For the word organisation:

In fact, while the US spelling is with a ‘z’ the UK preferred spelling is also with a ‘z’ and as an alternative with an ‘s’ if you follow the guidance from leading authoritative dictionaries. This is true even in my 1972 Concise Oxford Dictionary.

We could use something similar for words such as color (colour):


I include only the inside word ? option since replacement usually occurs at the end of a word when followed by a space or punctuation. Of course, typing the word “or” could cause a problem (or ⇒ our). (I might try to write an X subroutine which would resolve the problem.)

It might work better to add the individual words:


I think maybe I’ll just stick with the letter Z. You might find more innovative uses for these AutoHotkey Hotstring techniques.

Next time, back to discussing learning points in the InstantHotstring.ahk script.

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.)

2 thoughts on “Beginning Hotstring Tricks for Expanding Acronyms (AutoHotkey Tips)

Leave a Reply

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

You are commenting using your 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