AutoHotkey Tip of the Week: Fold Long AutoHotkey Menus into Columns

Sometimes We Resort to Programming Trickery to Make Autohotkey Menus Look Better

The Windows Menu control is part of the Windows operating system. AutoHotkey offers you the Menu command for setting up and altering custom menus using this built-in control. However, much of the inflexibility of AutoHotkey menus results from the limitations of the Windows Menu object itself. This rigidity often forces us to resort to programming sleight-of-hand to accomplish many goals. Continue reading

AutoHotkey Tip of the Week: Flexible AutoHotkey Hotstring Menus Using Arrays

New Parameters for the HotstringMenu() Function Adds Flexibility and Power to Pop-up Menus

In my last blog, I started looking at adding the variadic parameter (accepts multiple inputs) and a Menu subroutine parameter to the HotstringMenu() function. While in the process of creating alternative Label subroutines, I found that changing a subroutine often called for a new menu-creating function. Rather than resorting to multiple functions, I decided to add one more parameter for tailoring the master function.

CoverImage200
A Multitude of AutoHotkey Tips and Tricks

Note: This blog discusses the use of AutoHotkey object-based arrays (simple and associative) with the function’s variadic parameter. A review of my books demonstrated that most included discussions of arrays (pseudo-arrays and object-based arrays). In particular,  Chapter 12.1.5 “Using Associative Arrays to Solve the Instant Hotkey Data Recall Problem” in the book Jack’s Motley Assortment of AutoHotkey Tips explains the difference between the various array types while offering a practical example of an associative array.

Continue reading

AutoHotkey Tip of the Week: Use the Variadic Function Parameter for an Unknown Number of Values in Hotstring Menus

What To Do When You Don’t Know How Many Values You Will Use? For Hotstring Menus, the Variadic Function Parameter Allows a Variable Number of Arguments or Direct Array Input

Variadic Function: One which accepts a variable number of arguments.

MenuEmojiTagsLight Bulb!In the blog, “AutoHotkey Tip of the Week: Hotstring Menu Techniques for Inserting Symbols and Emojis“, I discussed switching from the deprecated StringSplit command to  StrSplit() function before posting the scriptAfter posting my new HotstringMenu.ahk script on the AutoHotkey forum, I received the following comment from the user Delta Pythagorean. I have mixed feelings about the recommended changes:

You can simplify this down by making the parameter variadic and letting the user chose which label to set the menu to work off of.

:x:brb::HotStringMenu("MenuLabel","Hello",,"Goodbye","See you later!")

MenuLabel:
  MsgBox, % "You said: " A_ThisMenuItem
Return

HotstringMenu(Handle, TextList*) {
  For Each, Item in TextList
    Menu, MyMenu, Add, % Item, % (Item != "") ? Handle : ""
  Menu, MyMenu, Show
  Menu, MyMenu, DeleteAll
}

I like the overall concept. This change to the HotstringMenu() function expands its capabilities by adding a selectable subroutine Label name and uses a variadic parameter which allows the functions to accept an unknown number of values. Continue reading

AutoHotkey Tip of the Week: Hotstring Menu Techniques for Inserting Symbols and Emojis

Place Special Characters and Emojis in Hotstring Menus to Make Them Easy to Find for Inserting into Documents, Plus Sample Hotstring Special Character Menus

MenuEmoji
Hotstring Menu

In my last blog, “AutoHotkey Hotstring Menus for Text Replacement Options“, I expanded upon the Hotstring menu technique discussed in Chapters Eight and Nine of my book Beginning AutoHotkey Hotstrings. While the menus work great, I noticed that, in many instances, the standard built-in Windows menu objects do not always make it easy to distinguish various characters. For example, when I placed a mix of symbols and emojis in a menu, it produced ambiguous results:

:x*?:b``::TextMenu("🦄,🐀,🐁,🐂,🐃,®,❓,❔")

The characters appear small in the menu (shown at right above)—often without clearly defined differences.

In the menu, the rat (🐀) and mouse (🐁) seem very similar—as do the ox (🐂) and the water buffalo (🐃). The two question marks at the end of the menu look identical, although, the first emoji inserts the punctuation mark in red (❓) while the second adds a white question mark (❔). We need another method for discriminating between the menu options. Continue reading

AutoHotkey Tip of the Week: AutoHotkey Hotstring Menus for Text Replacement Options

Put Hard-to-Remember AutoHotkey Hotstring Replacements in a Menu

Beginning AutoHotkey Hotstrings 200px

Light Bulb!

This tip expands on Chapter Eight of my book Beginning AutoHotkey Hotstrings, “Make Your Own Text AutoCorrect Hotstring Pop-up Menus with AutoHotkey” and Chapter Nine, “How to Turn AutoHotkey Hotstring AutoCorrect Pop-up Menus into a Function.” You can use these techniques in your AutoHotkey scripts to make the selection of similar Hotstrings easier to remember by selecting from a menu. Continue reading

AutoHotkey Tip of the Week: Understand How Hotstring Activating Text Works

Sometimes We Limit Our Scripts by Not Grasping How AutoHotkey Features Respond

In AutoHotkey, we use Hotstrings for automatic text expansion and replacement—as in the extensive list of common misspellings found in the AutoHotkey AutoCorrect.ahk script. After loading this series of Hotstrings, if you misspell one of these words, AutoHotkey instantly corrects it. I’ve included this as a standard part of my main AutoHotkey script and often watch the Hotstrings in action when they correct one of my typos or misspellings.

Beginning AutoHotkey Hotstrings 200pxWhenever a Hotstring fires, it resets and waits for the next one. Most commonly, this occurs when we type a space, period or other punctuation as a Hotstring recognizer. One might fall prey to the misconception that every such space or punctuation key press causes a Hotstring reset, but not so. Hotstring monitoring only resets when a Hotstring event occurs (or with a mouse click or cursor movement). That means we can include spaces and punctuation in the activating strings (or Hotstring definitions) which appear after the first double-colon.

Light Bulb!Most AutoHotkey users might understand this fact about Hotstring activators, but I write about it here for those of us who either never fully realized the importance of this aspect of Hotstrings or we just forgot. Knowing this fact allows for a number of additional types of Hotstrings rather than limiting ourselves to standard text expansion and replacement. A perusal of the AutoHotkey AutoCorrect script lets us peek into how we can take advantage of this aspect of Hotstrings. Continue reading

AutoHotkey Tip of the Week—Powerful RegEx Text Search Shorthand (~=)

AutoHotkey Provides an Abbreviated Regular Expression RegExMatch() Operator ( ~= ) for Quick Wildcard Text Matches

Regular Expressions (RegEx) can get confusing, but once understood, they pay tremendous dividends. Acting almost as another programming language, Regular Expressions in AutoHotkey provide a method for accomplishing complex search and/or replacement with only one line of code. While not impossible, doing the same thing without using RegEx often requires complex tricks and many lines of code. In the beginning, learning RegEx many feel daunting but you’ll find it well worth the journey.

Light Bulb!In spite of the initial learning curve, you don’t need to learn how the two primary AutoHotkey RegEx functions work (RegExMatch() and RegExReplace()) to make good use of a RegEx. The shorthand RegEx operator ( ~= ) provides a method for doing a complex string match without the limitations of the InStr() function. Regular Expressions search for patterns while the InStr() function searches for exact strings.

Continue reading