AutoHotkey Tip of the Week: Use the GUI Menu Bar for Instant Hotkeys

Rather than Creating New Hotkeys and Isolating Them Using the #IfWinActive Directive, Simply Add Keyboard Accelerators Using a GUI Menu Bar

Note: This week’s keyboard accelerator tip is not the same technique as adding an ampersand before any letter in a menu item—although that trick still works. The beauty of this technique lies in the fact that you can embed and execute a multitude of active window Hotkey-like actions in a menu bar without ever opening the menu itself.

In almost every one of my books, I discuss using the Menu command to build free-floating selection lists for a wide variety of tasks. I use menus for the HotstringMenu.ahk script, the QuickLinks.ahk favorites app, SynomynLookup.ahk, and numerous other purposes. In the GUI ListView control examples found in the AutoHotkey Applications book for the to-do list, the address book, the calorie counting app and listings of icon images, the right-click context menu pops open for individual action items. Menus provide an easy method for adding features to AutoHotkey scripts while saving space. I’ve always known that you can add a menu bar to the top of any AutoHotkey GUI (Graphical User Interface) but had little to say about it—until now.

ToDoListINI
The Ctrl+T in the menu bar item creates an accelerator key combination which, whenever pressed, acts as an active window Hotkey for instantly executing the option—even without opening the GUI menu bar.

While working on my latest to-do list script (ToDoListINI.ahk), I realized that I wanted to add a couple more options to the app, but I didn’t like the idea of inserting more buttons into the GUI. I naturally turned to a menu bar at the top of the GUI which could include many more actions while taking up minimal area. After a quick glance at the Gui, Menu command, I realized that I had routinely overlooked one of the most important aspects of Gui menu bars: accelerator keyboard combinations. Continue reading

AutoHotkey Tip of the Week: AltSubmit Prevents One-Click Field Editing in GUI ListView Control

Sometimes Adding More Capabilities to a GUI Eliminates Other Features

coverepub-250

Chapter Ten “More To-Do List App (Resizing and Positioning the GUI)” of  the AutoHotkey Applications book discusses “Direct Editing in the First Column Field of ListView.” This convenient feature mirrors the one-click editing you get when working with Windows File Explorer—the same effect as selecting Rename from the right-click context menu or hitting the F2 key. The feature makes it easy to change the name of a file or folder. I find this technique much simpler than editing text in a separate edit field then clicking an Update button, however, you can accidentally disable one-click editing in a GUI ListView when attempting to add other useful features by including the AltSubmit option. Continue reading

How to Use the Windows Registry to Save Data Table Records

Saving To-Do List Data Items in the Windows Registry Allows Interactive Realtime Updates from the GUI ListView Control

ToDoListReg

The GUI ListView control acts like a data table (i.e. interactive rows and columns). The ListView control includes a number of functions for adding, inserting, modifying and deleting rows and columns,—plus, even more functions for sorting and selecting rows, as well as, retrieving data. I’ve used the AutoHotkey ListView control for a to-do list (shown at right), an address book,  a calorie counting app and listings of icon images embedded in files. (I consider all of these apps educational tools or starting points for AutoHotkey scripting—not final products.)

The AutoHotkey ListView control operates in the same manner as Windows File Explorer—automatically sorting on clicked column headers with editing available in the first field of the selected row on a second click. When included in a GUI (Graphical User Interface), the control adds a great deal of flexibility to any data table display, but it does not automatically save the data. You must write that code yourself. Continue reading

AutoHotkey Tip of the Week: Save Time with CodeQuickTester for Testing and Modifying Scripts

Stop Creating Temporary Files to Check Out the New Scripts You Find on the Web—CodeQuickTester Directly Runs AutoHotkey Code without Saving

Since I consider educating motivated users about how to write and implement AutoHotkey scripts my primary purpose in life, I rarely recommend specific “user-friendly” AutoHotkey tools. Although they make scripting simpler, easy-to-use programming apps often interfere with a person’s understanding of the inner workings and hidden mechanism of AutoHotkey.

Don’t misunderstand me. I’m not against anyone using any tools that make life easier but my job is to teach how to get it done—not deliver canned, finished products. That’s why I rarely review other AutoHotkey scripts. However, every once in a while, I find an AutoHotkey app (such as Ryan’s RegExTester) which enhances understanding while making the coding process a little easier. CodeQuickTester by GeekDude falls into this category. Continue reading

AutoHotkey Tip of the Week: Increase the Flexibility of Menus by Passing Data with the BoundFunc Object

Streamline and Add Power to Hotstring Menus by Binding Action Parameters Directly to Each Menu Item

*          *          *

If you use AutoHotkey menus, then you may find this blog the most useful menu tip yet. At first, using the BoundFunc Object to pass data may seem confusing, but, once understood, it opens up many more opportunities for taking advantage of menus in your AutoHotkey scripts.

*          *          *

HotstringSubMenus

As often happens when working on an AutoHotkey script, a deeper understanding of the available tools completely changes the direction of the project. While all of the Menu tricks I’ve offered in the past HotstringMenu.ahk scripts still work (and you may want to continue using many of those techniques), the following approach which combines arrays, the variadic function parameter, and the boundfunc object creates a cleaner, more functional structure for generating Hotstring replacement menus. In short, implementing the boundfunc object allows me to drop many of those previous menu tricks and build menus using virtually any menu item format without regard for their later use through the value of the A_ThisMenuItem variable.

Continue reading

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