Eliminate Hotkeys with AutoHotkey Menus (AutoHotkey Tip)

Why Memorize a Bunch of Hotkey Combinations When Using an AutoHotkey Pop-up Menu Does the Trick?

A while back I talked about adding hard-to-remember AutoHotkey Hotkeys to the System Tray icon right-click menu. This saved me from needing to recall too many key combinations. As I worked on my last blog about creating the auto-startup script, I realized that I was again testing too many Hotkey combinations. Numerous combos activated other Windows or program functions. Since we can so easily set up AutoHotkey Hotkeys, we often go keyboard shortcut crazy—later finding that they interfere with others actions. Plus, remembering the various combinations doesn’t get any easier.

It dawned on me that I wanted an easier way to launch various AutoHotkey scripts without depending upon Hotkeys at all. This brought me back to my QuickLinks menu app.

Ever since I first wrote the short QuickLinks.ahk script, I’ve used it regularly. With a click of my first extra mouse button (XButton1), the menu pops up allowing me to select my most used actions.

The beauty of QuickLinks.ahk lies in the fact that it doesn’t require AutoHotkey code modification to tailor it to my needs. The menu structure comes directly from Windows folders (e.g. C:\Users\Jack\QuickLinks and the subfolders) and menu items captured from the Windows shortcuts in the subfolders initiate the action. QuickLinks requires no extra AutoHotkey Labels (subroutines) or Hotkeys. (Three chapters of the e-book Digging Deeper Into AutoHotkey discuss the QuickLinks.ahk script. Plus, Chapter Thirty of AutoHotkey Applications explains how to add icons to AutoHotkey menus.)

Use QuickLinks.ahk to Eliminate Hotkeys

Using AutoHotkey for the purpose of eliminating Hotkeys may seem a bit ironic, but ultimately it makes total sense. Everything gets easier when we use cheat sheets—even better when the cheat sheets initiate the action. A menu structure serves this purpose. By adding the scripts I regularly use (but not enough to make them part of my auto-load apps) to my QuickLinks menu, I get a fast, easy method for running those important apps without remembering (or accessing) any Hotkeys. QuickLinks.ahk builds the menus directly from Windows Explorer folder contents.

QuickLinksTools
All my main QuickLinks Folders reside in C:\Users\Jack\QuickLinks. Within each folder, Windows shortcuts comprise the submenu items for initiating action. Various AutoHotkey scripts appear in the Tools submenu allowing quick access to the script while requiring the use of no Hotkeys.

I wanted to add the AutoHotkey AutoStartup.ahk capability (which I discussed last time) to QuickLinks—allowing me to instantly make any program load during Windows logon—although I would only occasionally use the script. Permanently loading the AutoStartup.ahk script with Hotkey access seemed impractical since I would probably forget the key combination and need to look it up on each use. I could load it directly from my AutoHotkey folder, but that requires opening the folder, locating the script, then returning to the folder containing the target Startup app. For me, adding the script as a Windows shortcut to QuickLinks did the trick.

AutoStartShortcutProperties
Created by right-clicking on file name in Windows Explorer (File Explorer) and selecting Create shortcut, I dragged this shortcut linking the AutoStartup.ahk script into the QuickLinks/Tools folder. Then I selected Reload QuickLinks from the QuickLinks menu to reinitiate.

As shown in the top image, the shortcut for Windows Auto Startup (AHK) targeted at the C:\AutoHotkey\AutoStartup.ahk script appears in QuickLinks/Tools menu.  In Windows Explorer, I merely select the name of the program I want to add to the Windows Startup folder, then activate the QuickLinks menu (in my version, click XButton1):

XButton1::Menu, QuickLinks, Show ; added to QuickLinks.ahk

and select Tools/Windows Auto Startup (AHK) from the list. The script (AutoStartup.ahk listed below) loads and creates a Windows shortcut for the selected file in the Startup folder, then it terminates:

Clipboard =
Send, ^c
ClipWait 0
SplitPath, Clipboard, Name, Dir, Ext, Name_no_ext, Drive

IfExist, %A_Startup%\%Name_no_ext%.lnk
{
  FileDelete, %A_Startup%\%Name_no_ext%.lnk
  MsgBox, %Name% removed from the Startup folder.
}
Else
{
  FileCreateShortcut, "%clipboard%"
         , %A_Startup%\%Name_no_ext%.lnk, %Dir%
  MsgBox, %Name% added to the Startup folder for auto-launch with Windows.
}
Return

Note: I removed the Hotkey combination discussed last time from the script forcing it to run immediately and preventing the script from remaining active.

While I don’t discuss how to use QuickLinks.ahk here, you can find a fairly complete discussion of how to setup and use it at the “A Free QuickLinks Windows App from Jack” Web page.

Note that this approach to launching AutoHotkey scripts (and other programs) completely eliminates Hotkeys rather than merely adding them to an AutoHotkey Menu structure.

The QuickLinks.ahk script works directly with the associated Windows folders requiring the user to do all setup through the Windows folder system and manually create the needed Windows shortcuts.

Now that I’ve started working with the AutoHotkey FileCreateShortcut command and other related tools, I realized that I can make a number of other improvements to the script without limiting its current functionality. In the coming weeks in order to demonstrate the utility of a number of AutoHotkey commands I have not previously discussed, I plan to do just that.

jack

3 thoughts on “Eliminate Hotkeys with AutoHotkey Menus (AutoHotkey Tip)

  1. Hi Jack

    Both Dropbox links you gave for Quicklinks are inaccessible. I get an error 429 code every time. Any chance you could post an updated link somewhere?

    Regards

    John

    New Zealand

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s