Instantly Create and Save Hotstrings with the Hotstring() Function

Post your working scripts, libraries and tools
User avatar
jackdunning
Posts: 109
Joined: 01 Aug 2016, 18:17
Facebook: https://www.facebook.com/ComputorEdgeEBooks/posts
Contact:

Instantly Create and Save Hotstrings with the Hotstring() Function

19 Sep 2019, 13:59

Create and Test Hotstrings On-the-Fly—then, Save Them for Later Use

When the new Hotstring() function was added to AutoHotkey, I decided to explore its features and capabilities. Over the course of a couple of months, I developed the InstantHotstring.ahk script documenting it along the way in my blog: Jack's AutoHotkey Blog. You can find the source code at my Free AutoHotkey Scripts Page.

The InstantHotstring.ahk script quickly sets up and tests temporary Hotstring combinations for adding repeated and/or long lines of replacement text to any current Windows document or Web editing field. This comes in handy for those situations where you know what text, particular terms, or set of terms you will use repeatedly in a single session.

Image

The GUI window includes a GUI Edit control Hotstring Test Pad for checking the behavior of any newly set Hotstrings. When creating new instant Hotstrings, you can check out various options using the Hotstring Test Pad.

The Test Pad in the image shows the results of the Hotstring "GUI" which immediately appends " (Graphical User Interface)" inserting a preceding space without backspacing to delete the activating Hotstring.

Save Groups of Hotstrings

You can save the Hotstrings to an AutoHotkey *.ahk file of your choice in the [working directory/]Hotstring/folder. You can reload the saved Hotstrings from the any saved .ahk file. When saving the temporarily Hotstrings, you can choose to create a new file by adding a new filename, opt to overwrite an existing file, or, by selecting but not overwriting an existing filename, append more Hotstrings to that same file.

The InstantHotstring.ahk script displays newly created Hotstrings in the 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 Save Hotstrings button stores all currently active Hotstrings to a filename of your choice. The Load Hotstrings button restores and activates Hotstring code stored in that same (or another) file. (The Load function updates rather than duplicates any Hotstrings with the same activation characters.) The Start Clean button reloads the script wiping out all of the Hotstrings currently running in InstantHotstring.ahk.

The original LoadHotstrings subroutine ran slow for a number of reasons (for discussion in my AutoHotkey blog). I've rewritten it for speed but include the former script (InstantHotstring(SlowLoad).ahk) for review by those reading earlier blogs.

The GUI window for setting up the Hotstrings opens immediately when the script loads. After closing the Hotstring window, you can reopen it by right-clicking on the icon in the System Tray and selecting Show Instant Hotstrings.

November 13, 2019: The version of the script available at the Free AutoHotkey Scripts page now loads a default Hotstring file from a path and filename saved in the Windows Registry. Use "Save Hotstrings" button to set default file.

This script uses tips and tricks found in my AutoHotkey books and AutoHotkey blogs. To find my numerous blogs about the development of this script (in reverse order), search my blog using "InstantHotstring" in the primary search window.
Last edited by jackdunning on 13 Nov 2019, 17:52, edited 1 time in total.
burque505
Posts: 1158
Joined: 22 Jan 2017, 19:37

Re: Instantly Create and Save Hotstrings with the Hotstring() Function

19 Sep 2019, 17:14

Thanks, Jack. I created a very simplistic script along the same lines some time ago, see this thread.
Yours has all the bells and whistles. :D
User avatar
jackdunning
Posts: 109
Joined: 01 Aug 2016, 18:17
Facebook: https://www.facebook.com/ComputorEdgeEBooks/posts
Contact:

Re: Instantly Create and Save Hotstrings with the Hotstring() Function

13 Nov 2019, 17:46

The latest version of the InstantHotstrings.ahk script (download link) now loads the default Hotstring file by accessing the file path and name saved in the Windows Registry. To set the default, click the "Save Hotstrings" button for adding the loaded Hotstrings to a file, then, when prompted, opt to set the file as default.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Bing [Bot], geekyadam and 91 guests