Barebones AutoHotkey QuickLinks App

After Many Years, It’s Time to Take Another Look at the QuickLink.ahk Script

Since its early beginnings, the QuickLinks.ahk script (originally introduced as a replacement for the missing Windows 8 Start Menu in January 2013) has evolved both through this blog and others working through the AutoHotkey forum. It has grown in complexity which can make it a little difficult to modify for personal use. Recently, I took a closer look at the core of my version of QuickLinks.ahk and decided that the time has come for a rewrite—at least of the central code.

During the intervening years, I’ve learned a few things and feel I can build a cleaner more universal basic program—at least for the main routine. The same may apply to many of the added features. (Sometimes starting over makes the most sense.)

Also, the powers-that-be have deprecated some of the code. In particular, they replaced the old Loop command with the Loop, File command. The following script replicates the original QuickLinks.ahk app while replacing the deprecated code:

IfNotExist, C:\Users\%A_UserName%\QuickLinks\
	FileCreateDir, C:\Users\%A_UserName%\QuickLinks\
Loop, Files, C:\Users\%A_UserName%\QuickLinks\*.*, D
{
	Menu, QuickLinks, Add, %A_LoopFileName%, MenuHandler
	MainMenu := A_LoopFileName
	CountLoop := 0
	Loop, Files, %A_LoopFileFullPath%\*.*, F
	{
		if A_LoopFileAttrib contains H,R,S ;Skip any file that is
			continue ; H, R, or S (System).
		Menu, %MainMenu%, Add, %A_LoopFileName%, MenuHandler
		CountLoop := 1
	}
	If (CountLoop = 1)
	{
		Menu, QuickLinks, Add, %MainMenu%, :%MainMenu%
	}
	Else
	{
		Menu, QuickLinks, Add, %MainMenu%, FolderHandler
	}
}
Menu, QuickLinks, Add ;Add a separator bar
Menu, QuickLinks, Add, Edit QuickLinks, QuickLinksHandler
Menu, QuickLinks, Add, Reload QuickLinks, ReloadHandler
Menu, QuickLinks, Add, QuickLinks Help, HelpHandler
Return
MenuHandler:
run, C:\Users\%A_UserName%\QuickLinks\%A_ThisMenu%\%A_ThisMenuItem%
return
QuickLinksHandler:
run, C:\Users\%A_UserName%\QuickLinks\
Return
FolderHandler:
run, C:\Users\%A_UserName%\QuickLinks\%A_ThisMenuItem%
Return
ReloadHandler:
Reload
Return
HelpHandler:
Run, http://www.computoredge.com/AutoHotkey/AutoHotkey_Quicklinks_Menu_App.html
Return
!z::Menu, QuickLinks, Show
!.::Menu, QuickLinks, Show

(Changes to deprecated code appear in red.)

If you’re a current user of the app, this barebones version of QuickLinks.ahk should load the basic menu without all the bells and whistles added over the years. If new to QuickLinks, the script should set up the required directories. You can modify your own menu with the instructions found on the “A Free QuickLinks Windows App from Jack” page.

Note: You can find references to the evolution of the various features added to the QuickLinks.ahk script at the Free AutoHotkey Scripts page. You’ll find even more versions at the AutoHotkey Forum.

The original approach (shown above) for loading folder/file structures into an AutoHotkey menu limits the possibilities. These constraints originate with the basic Windows menu object itself which provides very few options for saving data. Since the time of the original design, I’ve learned about binding functions in AutoHotkey. (See, “Increase the Flexibility of Menus by Passing Data with the BoundFunc Object.”) This technique solves the problems presented when adding multiple levels of submenu to QuickLinks. Plus, I can write a routine which loads all files/folders into a menu including multiple submenus using only one Loop command.

Note: AHK_user has previously made adaptations to QuickLinks to include these solutions at “QuickLinks (Menu by folder).” I don’t plan to replicate his work, but merely explore the key techniques. (If you get an icon error when running this version, comment out the:

; Icon_Add(Folder1Menu,Linkname,A_LoopFileFullPath)

line of code by placing a semicolon ( ; ) in front of it.)

I don’t suggest that anyone should give up their current QuickLinks app. (I don’t plan to replace mine.) I merely want to explore the possibilities that present themselves when starting fresh.

Click the Follow button at the top of the sidebar on the right of this page for e-mail notification of new blogs. (If you’re reading this on a tablet or your phone, then you must scroll all the way to the end of the blog—pass any comments—to find the Follow button.)

jack

This post was proofread by Grammarly
(Any other mistakes are all mine.)

(Full disclosure: If you sign up for a free Grammarly account, I get 20¢. I use the spelling/grammar checking service all the time, but, then again, I write a lot more than most people. I recommend Grammarly because it works and it’s free.)

Find my AutoHotkey books at ComputorEdge E-Books!

Find quick-start AutoHotkey classes at “Robotic Desktop Automation with AutoHotkey“!

5 thoughts on “Barebones AutoHotkey QuickLinks App

  1. Thanks for that. How could you modify it such that instead of linking to a shortcut, instead it linked to user input text (for example a password reminder message etc)? Rgds Rob

    Like

    • You can link a Windows shortcut to any type of program. For example, the shortcut could call an AutoHotkey script which first provides password info, then loads a Web page.

      Like

      • Thanks. I don’t think I framed my orignal question all that well. The scenario I was trying to describe was this:

        1. You have a menu script which, for example, details keyboard shortcuts for different applications
        2. You would like users to be able to update the menu program themselves by filling out pop up fields rather than editing the script itself
        3. So for instance, a user would be able to select something like “Add new shortcut”
        4. A pop up field would appear for them to select the application (ie main menu item) which could be Chrome for example
        5. Another pop up field would appear to add the keyboard shortcut and description (for example) Then the user would enter the keyboard shortcut and description (for example Alt D – Select URL in address bar)
        6. On entering this, the shortcut would be added to the appropriate menu item (Chrome)

        Not even sure if this is possible? Of if it is, some pointers on how you would approach this would be appreciated, Thanks Rob

        Like

      • It’s certainly possible. How you would approach the script depends upon exactly what you hope to accomplish. If you don’t want to rewrite the code, then you will need to save your data in a file. In QuickLinks.ahk, the data comes from the shortcut files in the QuickLinks folder. You could just as easily use a standard CSV file to store data. Then you could write your script to add and update as necessary without touching the original code.

        I’ve written many blogs about using various types of external files to maintain data structures and the QuickLinks app contains a menu item for adding more to the QuickLinks menu—although it does not use separate pop-up GUIs, but it could.

        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