The Coming Instant Hotstring Script (AutoHotkey App)

The InstantHotstrings.ahk Script Allows the Creation and Testing of Hotstrings

Library Benefits

January 5, 2019 Update: You can find the InstantHotstrings.ahk script at the ComputorEdge AutoHotkey Free Scripts page.

I started writing the InstantHotstrings.ahk script as a demonstration of the new Hotstring() function. I planned to keep it basic. (See the previous blogs, “Create Instant Hotstrings Using the AutoHotkey Hotstring() Function” and “Using the AutoHotkey Hotstring() Function to Disable/Enable Hotstrings.”) However, as often happens, the script ballooned into much more. While it continues to demonstrate various aspects of the Hotstring() function, it now includes a number of other features worth discussing (e.g GUI DropDownList, adding Hotstring options, saving and loading files).

I plan to post the current version of the app soon, but I don’t feel it’s quite ready. So, in this blog, I review the script’s features which provide topics for my future blogs. Although not my intention, you could call this a teaser of what’s yet-to-come. I should have the script ready for posting next week. I’ll publish a notice here when I’ve added it to the ComputorEdge Free AutoHotkey Scripts page. (I didn’t want you to think that during this holiday period I wasn’t working on something.)

January 5, 2019 Update: You can find the InstantHotstrings.ahk script at the ComputorEdge AutoHotkey Free Scripts page.

In addition to the two blogs mentioned above, I will write a series of pieces about the meat and potatoes in this new app:

  1. Add Hotstring options to the activated Hotstrings and the GUI DropDownBox control.
  2. Discuss the behavior of the various Hotstring options within the Hotstring() function.
  3. Look at considerations when using the X (execute) option in the InstantHotstring.ahk script.
  4. Save temporary Hotstrings to a .ahk file.
  5. Use the FileSelectFile command to save/load Hotstrings.

The InstantHotstring App

You’ll find the new interface (the GUI window shown below) almost self-explanatory. The script has evolved from merely activating Hotstrings to adding options, using the GUI as a Hotstring test pad, and saving the newly created Hotstrings to a file. You can use the script for either adding Hotstring code to another script or temporarily loading the statements into InstantHotstrings.ahk at a later time:

The InstantHotstring.ahk script saves newly created Hotstrings in a DropDownList GUI control. When setting a Hotstring, AutoHotkey immediately activates it and adds it to the DropDownList. You can deactivate/activate Hotstrings using the Toggle Hotstring On/Off button. The GUI window includes an Edit GUI control Hotstring Test Pad for checking the behavior of any newly set Hotstrings. (The Test Pad above shows the results of the Hotstrings, “lol”, “Lol”, and “LOL”, respectively.) The Save Hotstrings button stores all currently active Hotstrings to a file. The Load Hotstrings button restores and activates Hotstring code stored in a file. The Start Clean button reloads the script wiping out all of the Hotstrings currently running in InstantHotstrings.ahk.

Using Hotstring Option Codes

By clicking the appropriate Hotstring option CheckBox control and hitting the Set Hotstring button, you can add and activate various Hotstring features. This gives you the opportunity to test combinations of options using the Hotstring Test Pad. The script saves the option codes to the DropDownList control emulating the Hotstring statement syntax. This matching format comes in handy when we later save the Hotstrings to an AutoHotkey file—for reloading, running separately, or use in other scripts.

Note: When using the X subroutine (Label) or function option, the Label or function must exist inside the InstantHotstring.ahk script before adding the execute option (X). While you can use some Hotstring options in conjunction with the X option, I found inconsistent behavior with a couple of them.

Tip: You can #Include a separate file of Labels and/or functions in InstantHotstrings.ahk for use with your temporary Hotstrings and the X option.

Since the Hotstring statements (saved in the DropDownList control) maintain the options as a string of characters placed between the first two colons, AutoHotkey must convert the CheckBox controls into the Hotstring syntax—and vice versa. Since this technique works in both directions, we set each appropriate CheckBox whenever selecting a Hotstring from the DropDownList control and, conversely, write the option string to the DropDownList statement whenever activating a new Hotstring.

Why the Test Pad?

When I started working on this script, I found myself testing the Hotstrings in the Text Replacement field as a matter of convenience. This worked fine but I had to remember to delete any spurious additions before resetting a Hotstring. Adding the Hotstring Test Pad made sense. I no longer needed to shift to another editing window or program for testing my results—helping me prevent accidental errors while saving time.

The Hotstring Test Pad doesn’t actually do anything other than act as a scratchpad for experimenting with Hotstrings.

Saving and Restoring Hotstrings To and From a File

If you’re the industrious type, you might find yourself setting up quite a number of temporary Hotstrings. But, after exiting the app, they all disappear. The obvious solution saves your work to a file—just in case you want to use the Hotstrings without re-entering them again. In fact, you may want to save different sets of Hotstrings in discreet files for various purposes—loading them as needed. Saving the Hotstrings in the DropDownList in AutoHotkey format provides the solution.

Once I get it implemented, you can select filenames for both saving and loading Hotstrings using the FileSelectFile command. The first posting of the InstantHotstring.ahk script may not include this feature, but it will write to and read from a fixed file name. (Until I add the file selection feature, you can use Windows File Explorer to change the filename for specific sets of Hotstrings.)

The initial posting of InstantHotstring.ahk will include basic functionality for all the above areas, but I expect a number of changes will occur in the script as I work on the various blogs.

January 5, 2019 Update: You can find the InstantHotstrings.ahk script at the ComputorEdge AutoHotkey Free Scripts page.

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





One thought on “The Coming Instant Hotstring Script (AutoHotkey App)

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 )

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