Submenus Allow AutoHotkey Users to Add Features to Apps Without Needing More Screen Space
Last time in “Adding Startup Folder Shortcuts to a System Tray Menu,” I inserted the Startup folder shortcuts into a System Tray right-click menu. This gave me a method for quickly accessing an auto-load script even when it doesn’t display an icon in the System Tray.
A click of the menu item either opens the script (.ahk) in Notepad or opens the target folder for a compiled executable (.exe) file. While the original menu does the basic job of keeping track of the auto-startup scripts, it only executes one action—opening a script or folder. To expand the capabilities of the Startup Control, we need to add submenus.
By Loading the Startup Folder Shortcuts into a Menu, We Can Access the Apps Even When No Icon Appears in the System Tray
Last time (“Collecting File Information from Windows Folders Using AutoHotkey“), I produced a simple MsgBox displaying the Windows shortcuts found in the Startup folder. When Windows launches, it reads and loads the programs or shortcut targets located in that folder. This provides AutoHotkey users an easy method for auto-loading their most-used scripts. However, the more scripts, the more clutter that appears in the System Tray in the form of AutoHotkey icons. You can reduce the crowding by adding the Menu,Tray,NoIcon command line to each script but then you need a technique for quickly reaching those hidden apps.
By inserting the shortcut names into a separate System Tray right-click context menu, you can both generate a list of shortcuts and provide quick access to the scripts. In this barebones AutoHotkey script, I create a menu that opens either the target script in Notepad (.ahk files) or the folder for the program (.exe files).
Add Shortcuts to Your Windows Startup Folder to Automatically Run Your Most Important Scripts
Every AutoHotkey user keeps a few favorite scripts at hand. Some people put them in one big master AHK file—auto-loading it when Windows boots. Others may use Windows Task Scheduler to initiate the apps. (See the “Windows Task Scheduler to Elevate Script Privileges” section of Chapter 16.1.4 of Jack’s Motley Assortment of AutoHotkey Tips.) Even more, add individual shortcuts to the Windows Startup folder for the preferred scripts. Each method has its advantages and disadvantages. In this blog, I visit AutoHotkey techniques for adding shortcuts to the Windows Startup folder.
After selecting an AutoHotkey script (.ahk) or compiled app (.exe) in Windows File Explorer, the Ctrl+Win+3 key combination creates a shortcut in the Startup folder—auto-loading the script on bootup. If the matching shortcut exists in the Startup folder, that same Hotkey combination removes it. While this barebones routine works fine, I began considering the implications of using the Startup folder for all my regular scripts. This prompted me to dig deeper into the possibilities.
When Using the Send Command to Paste from the Clipboard, a Simple Best Practice Can Make the Difference
I’ve noticed that occasionally a couple of my Clipboard paste Hotkeys would cause a jump to the Bottom of the page in the WordPress editing window—a huge source of aggravation. Fortunately, I rarely used those Hotkeys. Then, while working on my blog for next week, I ran into the problem again in a simple capitalization Hotkey routine. This confused me since my standard uppercase, lowercase, and initial cap Hotkeys work just fine. The new Hotkey wasn’t that much different. I investigated. Continue reading →
This Technique Accesses Icons Embedded in Windows Folders for Inserting into Pop-up Menus—Plus, the New Combined Switch/Case Statement QuickLinks QL_GetIcon() Function
I completely rewrote the functions from the last blog for adding icons to the menus in the QuickLinks.ahk script combining the two into a shorter prioritized list using Switch/Case statements. In the process—after investigating how to read icons embedded in Windows folder/directory listings—I discovered an interesting Windows secret. It turns out that this procedure requires a totally different Windows maneuver than that used for reading Windows Shortcut file icons.
The Windows Desktop.ini File
Ryan’s UnHideFiles.ahk script makes Windows Registry changes to hide and unhide files.
When you embed an icon into a Windows folder (right-click on the folder name in Windows File Explorer, select Properties and the Customize tap, then click Change Icon… and browse for icons), rather than saving the icon path and icon number in the folder itself—as Windows does for shortcut files—it creates a special hidden file named desktop.ini in that same folder. With Windows set to Show Hidden Files, folder and drives in the View tab of the Folder Options window, you can view the hidden desktop.ini file in that folder. (Tip: You can use Ryan’s UnHideFiles.ahk script to hide and unhide files and folders.) Continue reading →
Inserting Icons into Your AutoHotkey Menus Makes Options Standout and Easy to Navigate, But You May Need to Prioritize the Methods for Adding Icons
I’ve employed icons in my QuickLink.ahk script for many years, but the process I used for adding them to menu items always felt awkward and messy—too much special-purpose code.
I want the script to standalone without needing much tailoring. Most changes should occur in Windows File Explorer by creating folders or editing shortcuts. Then the QuickLinks.ahk script should read all the Menu items from that folder/file structure—including menu icons. However, my implementation of icons gets a bit sloppy. For my own QuickLinks, I added numerous special lines of code to deal with the inconsistencies in how Windows deals with folder and file icons. I’ve never felt comfortable with how it worked.
My recent work implementing the Switch/Case statements has prompted me to return to my original goal of producing a script needing little or no adapting. That means not onlyconstructing the AutoHotkey menu directly from the folder/file structure shown in Windows File Explorer, but the menu icons themselves should load from those folders and shortcut files without requiring additional unique lines of AutoHotkey code in the script.
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 controlexamples 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.
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 →
Curly Brackets {…} in Hotstrings Both Insert Special Features and Neuter Hotkey Modifying Characters—When Properly Used, They Add Flexibility to AutoHotkey Hotstrings
Sometimes you want to do more than simple text replacement with your AutoHotkey Hotstrings. The key to adding those special features lies with embedding either manual keys within curly brackets (i.e. {Left 5}) or adding Hotkey action directly (without curly brackets) such as CTRL+I (^i for italics) or CTRL+B (^b for bold). The fact that the curly brackets {…} behave in two different manners can cause confusion. Continue reading →
If You Work with a Word Processing Program (Local or Web-Based) Which Supports Control Characters for Special Formatting, Then, Possibly, You Can Add Auto-Italics (or Bold, Underline, Etc.) to Your Autohotkey Hotstrings
Thanks for making such useful contributions to AHK.
I found QuickLinks to be useful but then was looking to make it even more helpful by having key shortcuts. I figured out how to do it! You can let others know if you can point out adding an ampersand in front of the letter of the folder or shortcut.