Access a folder

with AutoHotkey

by Denis Lamarre
last updated April 4, 2016
difficulty.png Easy

by Denis Lamarre

Description

Do you often use Windows Explorer to open folders? Perhaps it’s a folder for this year's Excel spreadsheets or a folder that contains downloads. Desktop shortcuts can be used to access popular folders, but doing so means having to minimize all of your open windows, locating the shortcut, clicking the shortcut icon, and then reopening all of your active windows again. If this is your experience, the Enterpad/AHK combo will be a time-saver.

With this simple AutoHotkey script, the folder will open in front of all of your open windows, without you having to minimize them, locate the Desktop shortcut, or search for the actual folder.

Note: AutoHotkey has no limits when it comes to automation in Windows, but for many users who may only need simple keyboard shortcuts, installing and learning AutoHotkey, and keeping up to date, can be overkill. ShortKeeper can be used (with and without an Enterpad) to manage an AutoHotkey-based system in a way most non-programmers will find remarkably user-friendly and and effective [learn more].

Steps

1

stencil-v4-folder.gifPrepare your overlay
Choose an unassigned key on the Enterpad where you will assign the folder shortcut. Name it something relevant, like the folder name.

2

Code installation
Copy and paste the script below in your AutoHotkey script template (Enterpad.ahk) at the location of the key you wish to assign. Replace the path in the code (C:\Users\John Doe\Documents\ThisYear) with the path of your folder. To get the path, you can open the folder in Windows Explorer and then copy it from the address bar at the top.

002:
  run Explorer "C:\Users\John Doe\Documents\ThisYear"
return

More Info

Special characters

Spaces in the path name won't cause a problem. However, should your path contain AutoHotkey special meaning characters ( ` ), (%), ( , ), or ( ; ) you will need to escape them with a backtick ( ` ). For example; if (%) appears in the path name you will have to add a backtick before it, like this (`%).

You may want to use the following script (and maybe save it as a key on your Enterpad) to automatically put the backticks before each special meaning character of the clipboard content, and paste the result at whatever point your cursor is at:

AhkFriendlyPath := RegExReplace(Clipboard, "(``|`%|`,|`;)", "``$1")
  SendInput {raw}%AhkFriendlyPath%
return

Options

The “Access a folder” script runs File Explorer with its default options. You can set useful options after “Explorer”. The following example starts File Explorer with the ThisYear folder selected (instead of opened):

run Explorer /select`,"c:\users\John Doe\Documents\ThisYear"

You can find more about Windows Explorer options at: (http://support.microsoft.com/kb/152457).

Environment variables

Some AutoHotkey environment variables can be useful for the path name. The following example opens the current user's "My Documents\ThisYear" folder:

run Explorer "%A_MyDocuments%\ThisYear"

You can find all the AutoHotkey environment variables at:
(https://www.autohotkey.com/docs/Variables.htm).