Windows

Customize the [Windows]+E key shortcut to open what you want

Greg Shultz shows you how to use AutoHotkey in Vista to re-route the [Windows]+E so that Windows Explorer opens a folder of your choice. He also provides you with a list of all of the standard [Windows] key shortcuts.

I've recently received several requests from TechRepublic members wanting to reprogram or customize the [Windows] key. More specifically, people have asked me if there was a way to reprogram the [Windows]+E key shortcut such that, instead of launching Windows Explorer targeted on the Computer folder, [Windows]+E could be used to launch Windows Explorer targeted on the folder of your choice. For example, you might want the [Windows]+E key shortcut to open Documents. Fortunately, I've discovered a way to accomplish this task by using a free utility called AutoHotkey.

In this edition of the Windows Vista and Windows 7 Report, I'll show you how to use AutoHotkey in Vista to reroute the [Windows]+E so that Windows Explorer opens a folder of your choice. As I do, I'll provide you with a list of all the standard [Windows] key shortcuts.

This blog post is also available in PDF format in a free TechRepublic download.

The standard [Windows] key shortcuts

Before I show you how to use AutoHotkey to reroute the [Windows]+E, let's take a look at the default [Windows] key shortcuts in Vista (see Table A). Of course, pressing the [Windows] key by itself opens and closes the Start menu. More Windows shortcuts are available in this TechRepublic download.

Table A

[Windows] +

Action/Description

1-9 & 0 Launches applications on the Quick Launch toolbar. You can have up to 10 shortcuts on the Quick Launch toolbar to use with the [Windows] key. The first shortcut on the Quick Launch toolbar is automatically assigned to [Windows]+1, the second shortcut to [Windows]+2, and so on. The tenth shortcut is automatically assigned to [Windows]+0
B Selects the first icon in the Notification Area. If you have the Hide Inactive Icons setting enabled, the Show/Hide toggle arrow will be selected. You can then use the right and left arrow keys to select whatever icon you want.
D Shows the desktop. This will minimize all open windows so you can see the desktop.
E Launches Windows Explorer targeted on the Computer folder.
F Launches the Search tool.
[Ctrl]+F Launches the Find Computers tool.
G Switch between gadgets on the Windows Sidebar.
L Locks the system.
M Minimizes all open windows.
[Shift]+M Restores all minimized windows.
R Launches the Run dialog box.
U Launches the Ease of Access Center.
T Cycles through programs using the Live Taskbar feature.
[Break] Launches the System window.
[F1] Launches Windows Help and Support.
[Spacebar] Brings the Windows Sidebar to the foreground.
[Tab] Launches the Flip 3D task switcher.

Using AutoHotkey

AutoHotkey is a FREE program that allows you to create customized macros that can perform all sorts of operations. Keep in mind that AutoHotKey has much more potential than simply rerouting the [Windows]+E, but for now, I'll only show you how to use the utility to perform this relatively simple operation. You can learn more about AutoHotKey's extensive list of features in its Help system and on the Documentation page of the AutoHotKey Web site.

Once you download the installation program, installing AutoHotkey is a snap. You just follow the steps presented by the setup wizard and respond with the appropriate action in the User Account Control dialog box.

AutoHotkey doesn't really have a user interface, so to speak. Rather, you create short scripts in Notepad that contain a hotkey definition and an action that you want to perform. Once you create a script, you double-click it to load the AutoHotkey application and the script into memory. AutoHotkey then runs in the background and waits for you to press the assigned hotkey. When you do, it launches the associated action.

AutoHotkey allows you to use any keystroke combination as its hotkey -- even keystroke combinations that are already assigned by other programs. Therefore, AutoHotkey allows you to override existing keystroke combinations.

One of the keys that AutoHotkey will allow you to customize is the [Windows] key. You can essentially reprogram the [Windows]+E key to open any folder that you wish. Let's take a closer look at how you will accomplish this.

Once you install AutoHotkey, it adds an item to the New menu called AutoHotkey Script. Choose a folder where you want to create your scripts and then right-click and select the New | AutoHotkey Script command, as shown in Figure A. When the new script appears, the default filename is highlighted so you can easily rename it. As you do, be sure not to change the file extension from .ahk.

Figure A

To create a script, just right-click inside a folder and select the New | AutoHotkey Script command.

To continue, right-click on the file and select the Edit Script command. When Notepad opens the file, you'll see the contents of the default template. In the template, the lines that begin with a semicolon (;) are comment lines and can be deleted if you wish. The other lines in the template are used to customize the environment for the script and should be left as they are.

To reprogram the [Windows]+E key to open any folder that you wish, use the following command line:

#e:: Run explorer.exe {FolderPath}
Where {FolderPath} is the path to the folder that you want to open when you press the [Windows]+E key. For example, to configure the [Windows]+E key to open my Documents folder, my script contained the command line listed below and shown in Figure B. That's all there is to it!
#e:: Run explorer.exe C:\Users\Greg Shultz\Documents

Figure B

To reprogram the [Windows]+E key to open my Documents folder, I used this simple command along with the path to the Documents folder.
Once you have created your script, double-click it to load the application and the script into memory. You'll then see the AutoHotkey icon appear in the Notification Area, as shown in Figure C. This indicates that your hotkey script is ready and waiting for you to press the [Windows]+E key.

Figure C

You can use this simple command line to reprogram the [Windows]+E key.

To configure your script to run every time you launch Windows, create a shortcut to the script and copy it to the Startup folder. Now, whenever you press the [Windows]+E key, Windows Explorer opens the folder that you specified in your script.

Other Windows versions

In addition to using this technique in Vista, I also tested it in Windows XP and it works fine. However, keep in mind that AutoHotKey does not officially mention support for Windows 7, and I have not verified that AutoHotkey will work reliably in Windows 7.

What's your take?

Do you use the [Windows] key shortcuts? Have you wanted to reprogram the [Windows]+E so that it could be used to launch Windows Explorer targeted on the folder of your choice? Will you use this technique to reprogram the [Windows]+E key?

TechRepublic's Windows Vista and Windows 7 Report newsletter, delivered every Friday, offers tips, news, and scuttlebutt on Vista and Windows 7, including a look at new features in the latest version of the Windows OS. Automatically sign up today!

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

15 comments
Xahi4475
Xahi4475

I use Windows Server 2003 and Win+E opens Explorer focused on left side (Folders). I wish to be opened My Computer with Common Tasks and, of course, focused on Drives. I can't find My Computer's path, I made some search through Google and looks like not possible to use My Computer on this trick. But is there any possibility for it? For now with Win+E I open My Documents (D:\) thanks to this page. Thank You very much. Thank You also if you find me way to open My Computer with Win+E . :)

bjendrick
bjendrick

I simply love, love, love AutoHotkey, and in fact, I have a large (157 KB) AHK script that runs on my system at startup. I've conveniently named it the "OS Commander", and along with a whole host of keyboard shortcuts, I've also included a vast number of auto-text replacements. I've grown so accustomed to these that I found them severely lacking on my work computer & ported the whole script to that as well. So now I no longer have to type out Wednesday, but simply "wday" & with a trailing space I can continue on my merry way. Plus, a nice advantage that w_lovewell pointed out is that I have a copy of the script on my thumbdrive, so if I find myself working on a friends computer, I insert the thumbdrive (OS Commander is part of the initial load sequence), and I have all of my commands at my fingertips without relying on the Properties dialogs. Granted, everyone has their preference, and I'd never bemoan someones tricks that increase productivity. AHK is an amazing tool, lots of fun to implement new things, and forever growing to customize my system with a simple text file. Thanks for another great tip!

dbm1rxb
dbm1rxb

Thanks Greg, good information to have.

Tin Weasle
Tin Weasle

I note that your example path doesn't use quotation marks around a path name containing a space: #e:: Run explorer.exe C:\Users\Greg Shultz\Documents I had thought you needed quotation marks to prevent Windows from parsing the bit after the space as another parameter. I would have guessed that #e:: Run explorer.exe "C:\Users\Greg Shultz\Documents" was the right way to do it. Have I just admitted my membership to the Old Dinosaur Syntax Club?

w_lovewell
w_lovewell

Hi Greg. I use shortcut keys for everything. I use AutoHotKey for a few things, but I mostly just keep icons for the things I most frequently use on the desktop and define a Shortcut Key in the properties-seems a little faster than AutoHotKey. Thanks for the Windows+x tips--I'd used a window-key-less keyboard for so long I've not made much use of that. One thing that really bugs me about opening up Explorer with AutoHotKey or with a Shortcut key assigned to a desktop shortcut for explorer (e.g. "c:\windows\EXPLORER.EXE /n, /e, c:\temp") is that I can't get any combination to open the SAME Explorer window--they always open a new one. Any ideas? -Wendell

Mark W. Kaelin
Mark W. Kaelin

What is your most often used shortcut key? What function or Windows action do you wish had a shortcut key?

sergiu.nomad2
sergiu.nomad2

I've experimented with explorer.exe file (sure, i made a copy of it before that).. however, when i replaced the backup of explorer, i noticed that i lost the Windows+E functionality.. and now i have an error popup each time i use it.. :( very sad.. can anyone help me? maybe it is made from the registry somehow? please :'(

Greg Shultz
Greg Shultz

Since this command line is executed from within an AutoHotKey script file, the quotation marks are not needed. Now, if you were using this command line from the Command Prompt or the Run dialog box, you would indeed need to have the quotation marks.

seanferd
seanferd

like Program Files or Documents and Settings, then I believe you do need the quotes.

seanferd
seanferd

for Explorer. /n opens a new window.

Greg Shultz
Greg Shultz

...just add a check to see if the window is already open to the AutoHotKey script by using the IfWinExist and WinActivate commands. Here is my modified script example: #e:: IfWinExist, Documents WinActivate else Run explorer.exe C:\Users\Greg Shultz\Documents

Amnezia
Amnezia

Firefox, ctrl + W to close current tab. Whoever thought of that one is brilliant!!

Tin Weasle
Tin Weasle

I thought it might be something like that, just wanted to be sure. Nice article, Greg! As an old DOS-osaur, I'm always looking for mouseless methods.