Access a folder

with AutoHotkey

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

by Denis Lamarre

Description

Do you have to repetitively use Windows Explorer to open folders. It might be a folder for this year's Excel spreadsheets, a folder that contains downloads or any kind of working folder.

Desktop shortcuts can be used to access popular folders, but doing so means that the user has to minimize all of their open windows, locate and click the shortcut icon, then eventually reopen all of their active windows again. If this is your experience, or your employee's time-waster, the Enterpad/AHK combo can be a time-saver.

With this simple AutoHotkey script, a folder can now appear on top of every other window without having to close other windows to find the Desktop shortcut or conducting a 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 a free key on the Enterpad for which you want to open a frequently-used folder. Name it something relevant, like the folder name.

2

Code installation.
Copy/paste the following script in your AutoHotkey script template (Enterpad.ahk) at the chosen key location. Replace our sample path (C:\Users\John Doe\Documents\ThisYear) with your path. To do so, you can open Windows Explorer to the folder you would like to access, and then copy/paste the entire path from the address bar at the top of your Windows Explorer window.

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).