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“!

3 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

Leave a Reply to Adding Folders and Files from Windows to AutoHotkey Menus | Jack's AutoHotkey Blog Cancel 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 )

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s