Windows Hot Keys with AutoHotKey

AutoHotkey_logoI’m a big fan of keeping my hands on the keyboard as much as possible and having real quick easy ‘one-touch’ access to my favorite apps, web sites, and tasks.  It’s just amazing how much more productive one can be when using the keyboard instead of the mouse.  Think of any common app you use in which you have a keyboards shortcut memorized, Ctrl-C to copy, Ctrl-V to paste, IE? Alt-D for the address bar, Word? Ctrl-S to save, Vista? Win key for the Start Menu, etc now imagine the power of having most all of your common tasks that quickly available, yup, pure power.

Now here’s the ultimate hotkey tool, AutoHotKey .  It is a simple ‘scripting’ like app.  It doesn’t have a graphical user interface, but is configured through plain text .ahk files.  Not only can you create hotkeys, but also script other parts of Windows, but I’ll focus this post on the hotkeys.  It is open source, been around a long time, is small, takes little memory, has a great help doc, a strong community, and is easy to use.

AutoHotKey will also allow you to override Windows default hotkeys, like Win-X for the mobility center in Vista.  I have a single .ahk file that loads at startup so the hotkeys are always hooked up.  To do this, first install AutoHotKey, then:

  1. With any text editor (aka Notepad), create a new .ahk file
  2. Add some lines to it for each hotkey (like the ones below)
  3. Add a shortcut to the “Startup” folder in your Start Menu

Some basic hot keys I use are:

Win-X Open favorite web browser
Win-W Open favorite text editor
Win-O Execute the contents of the clipboard
Win-C Open a command prompt
Win-2 Turn off the laptop display to conserver power
Win-` Google Search with the clipboard contents
Win-Ctrl-` Use Google’s ‘I Feel Lucky’ to open the clipboard contents
Win-Shift-O Open a URL in the clipboard
Win-Ctrl-1 Set the screen resolution to 1024x768
Win-Ctrl-2 Set the screen resolution to 1280x1024
Win-Ctrl-6 Set the screen resolution to 1600x1200
Win-Ctrl-8 Set the screen resolution to 800x600
Win-Ctrl-9 Set the screen resolution to 1920x1200
Win-Ctrl-0 Set the screen resolution to the highest the monitor supports
Win-Ctrl-Z Open Microsoft Outlook
Win-Ctrl-X Open Microsoft Excel
Win-Ctrl-W Open Microsoft Word
Win-Ctrl-O Open Microsoft OneNote
Win-Ctrl-V Open Microsoft Visual Studio
Win-Ctrl-B Open Microsoft Live Writer (to Blog)
Win-Shift-S Open a specific OneNote page, “Stream of Consciousness”
Win-Shift-Ctrl-E Edit my master AutoHotKey .ahk file to easily add new hotkeys.
Win-Shift-Ctrl-R Reload my master .ahk file to apply recent changes.
Win-Shift-Ctrl-T Open the AutoHotKey help (.chm) file for reference.
Win-Shift-Ctrl-Y Open AutoHotKey’s Spy Utility

To give an idea for other things you can assign hotkeys for, I’ve got hotkeys to open favorite text files, folders, remote desktop connections, specialty applications, enter login credentials, create a new email to my wife, and a few hotkeys that perform misc repetitive tasks depending on the application.  For other shortcuts, I use SlickRun, which is little commands to the same types of resources, just many more of them.

DownloadIconSmall   Download HotKeys.ahk (the file below) (also download AutoHotKey)
 ; ============================================================================
; == Basic keyboard shortcuts
; ============================================================================

; #=Win ^=Ctrl +=Shift !=Alt

; Open favorite webbrowser
#x::   Run about:home

; Open favorite text editor
#w::   Run %edit%

; Execute the contents of the clipboard
#o::   Run %clipboard%

; Open a command prompt
#c::   Run %ComSpec%

; Google Search for clipboard contents
#g::   Run https://www.google.com/search?q=%clipboard%
#`::   Run https://www.google.com/search?q=%clipboard%

; Use Google "I Feel Lucky" to navigate to the clipboard contents
#^`::  Run https://google.com/search?btnI=I`%27m+Feeling+Lucky&q=%clipboard%
#^g::  Run https://google.com/search?btnI=I`%27m+Feeling+Lucky&q=%clipboard%

; Open the clipboard contents with Internet Explorer
#+o::  Run "%ProgramFiles%\Internet Explorer\iexplore.exe" %clipboard%

; Set screen resolutions
#^1::  Run "%tools%\QRes.exe" /x:1024 /y:768  /c:32
#^2::  Run "%tools%\QRes.exe" /x:1280 /y:1024 /c:32
#^6::  Run "%tools%\QRes.exe" /x:1600 /y:1200 /c:32
#^8::  Run "%tools%\QRes.exe" /x:800  /x:600  /c:32
#^9::  Run "%tools%\QRes.exe" /x:1920 /y:1200 /c:32
#^0::  Run "%tools%\SetHighestResolution.exe"

; Open Microsoft Office Applications
#^z::  Run "%ProgramFiles%\Microsoft Office\Office12\OUTLOOK.EXE"
#^x::  Run "%ProgramFiles%\Microsoft Office\Office12\EXCEL.EXE"
#^w::  Run "%ProgramFiles%\Microsoft Office\Office12\WINWORD.EXE"
#^o::  Run "%ProgramFiles%\Microsoft Office\Office12\ONENOTE.EXE"

; Open Windows Live Writer
#^b::  Run "%ProgramFiles%\Windows Live\Writer\WindowsLiveWriter.exe"

; Open Visual Studio
#^v::  Run "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"

; Edit the master AutoHotKey file
#^+e:: Edit

; Open the AutoHotKey help file for reference
#^+t:: Run "%ProgramFiles%\AutoHotkey\AutoHotkey.chm"

; Open the AutoHotKey spy utility
#^+y:: Run "%ProgramFiles%\AutoHotkey\AU3_Spy.exe"

; Reload this AutoHotKey script
#^+r::
  SoundPlay *64
  Reload
  Sleep 1000
  MsgBox 4, , Script reloaded unsuccessful, open it for editing?
  IfMsgBox Yes, Edit
return

; Turn off the monitor (to save laptop battery power)
#2::   
  Run "%tools%\nircmd.exe" monitor off
  Sleep 1000
  Run "%tools%\nircmd.exe" monitor off
return

Some of these commands use the tools: NirCmd, QRes, SetHighestResolution

These also depend on some system environment variables being set:

  • edit = path to favorite text editor, eg: c:\windows\notepad.exe (my favorite, Notepad2)

  • comspec = path to your favorite command prompt, eg: c:\windows\system32\cmd.exe

    (my favorite, 4NT)

  • tools = directory to directory of command line tools, eg: c:\tools

Related Community Topics

Related Posts

Question for You: What are some of the things you use AutoHotKey for?