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