HotstringMenu.ahk includes the Hotstring menu function HotstringMenu(TextList) and subroutine HotstringMenuAction. Originally discussed in the book, Beginning AutoHotkey Hotstrings: A Practical Guide for Creative AutoCorrection, Text Expansion and Text Replacement, you can include virtually any replacement text or characters in the pop-up menu Hotstrings.
The function and subroutine create an action menu of replacement options when activating the Hotstring. Call the function using the Hotstring Execute Option (X) in the form:
Code: Select all
:x*?:b``::HotstringMenu("🦄 | Unicorn &1
,🐀 | Rat &2,🐁 | Mouse &3
,🐂 | Ox &4,🐃 | Water Buffalo &5
,🐄 | Cow &6,❓ | Red &7
,❔ | White &8")
Code: Select all
HotstringMenu(TextList)
{
MenuItems := StrSplit(TextList, "`,")
Loop % MenuItems.MaxIndex()
{
Menu, MyMenu, add, % MenuItems[A_Index], HotstringMenuAction
}
Menu, MyMenu, Show
Menu, MyMenu, DeleteAll
}
HotstringMenuAction:
InsertText := StrSplit(A_ThisMenuItem, "|")
TextOut := StrReplace(RTrim(InsertText[1]), "&")
SendInput {raw}%TextOut%%A_EndChar%
Return
; Sample Hotstring Menus
:x*?:$``::HotstringMenu("¢,£,¥,€")
:x*?:f``::HotstringMenu("⅒,⅑,⅛,⅐,⅙,⅕,¼,⅓,⅜,⅖,½,⅗,⅝,⅔,¾,⅘,⅚,⅞")
:x*?:s``::HotstringMenu("©|Copyright,®|Registered,™|Trademark,°,•,·,…,¶")
:x*?:m``::HotstringMenu("±,×,÷,≈,≅,∑,ƒ,¹,²,³")
:x*?:a``::HotstringMenu("⇐,⇔,⇒,⇑,⇓")
:x*?:b``::HotstringMenu("🦄 | Unicorn &1,🐀 | Rat &2
,🐁 | Mouse &3,🐂 | Ox &4,🐃 | Water Buffalo &5
,🐄 | Cow &6,❓ | Red &7,❔ | White &8")
:x:flux::HotstringMenu("Flux|&0,Flux #&1,Flux #&2")
The delimiting vertical bar makes possible the addition of descriptive tags and single-key shortcuts (e.g. &1, &2, &3, …) which won't appear in the replaced text.
For more information, see the following blogs:
AutoHotkey Hotstring Menus for Text Replacement Options November 4, 2019
Hotstring Menu Techniques for Inserting Symbols and Emojis November 11, 2019
December 9, 2019 Update
I've posted a rewritten version of the function which takes advantage of arrays, the variadic function parameter, and the boundfunc object.