PowerNotebooks.com - Laptop & Notebook News & Articles
Links:Articles Home
Tips and Tricks Category Index
AutoHotkey: Taking shortcuts to the next level
20 November, 2009 in Tips and Tricks
So you know the basic Windows shortcuts, and you may even use them, but do you ever find yourself wishing there were shortcuts custom-fitted to your own needs?
It takes a little bit of work and know-how, but AutoHotkey is an amazing productivity booster for anyone who would like to cut a few steps out of their routine.
Autohotkey is capable of creating shortcuts to any program and just about any action imaginable, so long as you know how to open the program or complete the action, or so long as a script can be found online (an excellent repository of custom scripts can be found here).
Once you have installed AutoHotkey, the first thing you should do is move it into your Start Menu's startup folder. To do this, simply drag the program's shortcut to your start menu until it pops open, then drag it to All Programs until it pops open, then to Startup until it pops open and place the AutoHotkey shortcut inside the Startup folder. To edit the default AutoHotkey script, just right-click the green "H" icon and select "Edit Script." Once you are through editing the script and have saved it, just right-click the green "H" again and select "Reload Script" to put it into effect
One of the most basic (and handy) uses for Autohotkey is as a means of quick-launching essential applications.
To create a quick-launch shortcut, simply load up the sample script included with Autohotkey and insert a line like the following:
#C::Run C:Windowssystem32calc.exe
This command tells Autohotkey to react to the Windows Logo Key + C as a command to launch the Windows calculator, and it works with all versions of Windows. The Run command can also be used to launch a webpage, as in the following:
#G::Run http://www.google.com
This command launches Google in the active window when the Windows Logo Key and G are pressed together.
The basic "script" key-tags for Autohotkey are:
Ctrl: ^
Alt: !
Windows: #
To set up any program-launching hotkeys, just use our handy Windows shortcuts article to make sure the shortcut you want isn't already taken, type in the shortcut, using any combination of ^, !, or # along with a standard key for launching, use the double colon (::), then type in Run and insert the path to whatever application you want to launch. The easiest way to get the path is to find the program's shortcut on your start menu, right-click that shortcut, and select properties. Copy everything inside the "Target" box and paste it after the Run command, just like the Calculator script above shows.
Autohotkey's scripting system uses a basic kind of markup language that accepts Run, Send, MessageBox (MsgBox), If/Then commands, and many more for the more technically-savvy, and it can even be used as a kind of universal autocorrection and text clippings tool for any text strings you enter.
Autohotkey's own tutorial site gives the following examples for sending keystrokes, but the possibilities truly are endless.
^!S::
Send Sincerely,{Enter}John Smith{Enter}Examples Unlimited
return
This command sets Ctrl+Alt+S as a signature hotkey that will automatically insert a three-line signature wherever you are typing (the {Enter}command simulates pressing Enter to go to the next line, and any keystroke that would normally be a script trigger should also be enclosed in {}, including !, which is the script trigger for Alt), but this next command is even more indicative of the fantastic possibilities for Autohotkey:
::btw::by the way
This command converts the characters "btw" into the full phrase, "By the way," whenever you type "btw" followed by either a space or a comma.
While this example may seem underwhelming, Microsoft Office users probably know exactly what significance that particular script holds. Autohotkey can effectively be used to build a universal "Autocorrect" dictionary, which can be used either to convert a small string of text into a complete phrase (or even a complete paragraph), or, more basically, it can be used to automatically correct commonly misspelled words, as in the following example:
::teh::the
The example above simply takes a common misspelling of "The" and automatically corrects it.
One word of warning about using AutoHotkey as an autocorrection tool for building phrases. Never have it autocorrect a word you might actually use. Autocorrection phrases work best with abbreviations, so, for example, if you wanted the signature above as an autocorrection instead of a hotkey, it would be better to set its autocorrection to "sig" rather than "signature," as you may very well use the word signature in day-to-day writing, but it is safe to assume that the abbreviation will only ever be used to trigger the signature. To use the signature above as an autocorrection, simply use the following script:
::sig::
Sincerely,{Enter}John Smith{Enter}Examples Unlimited
As long as you remember to use the {Enter} command for line breaks, an AutoHotkey autocorrect can be as long as you like. It can even store entire form letters, if you so please.
The biggest advantage of using Autohotkey instead of Microsoft Office's built-in autocorrect dictionary is that Autohotkey's autocorrections work anywhere, so rather than being limited to Microsoft Office, common misspellings or stored phrases, paragraphs, or whole letters can be inserted absolutely anywhere, whether it be a webmail account, a blog comment thread, an instant messenger client, or even notepad. Autohotkey's developers have a script loaded with about 4,700 automatic spelling correction entries here, and there is a tutorial that goes into much greater detail on making Autocorrects and includes a script allowing you to automatically create new autocorrects here.
This last script should get the more programming-oriented users thinking, and is actually quite useful for anyone who never touches the CapsLock key. This script is Windows XP only, unfortunately, but it effectively disables the CapsLock key by turning it into a handy audio mute button:
CapsLock:: SoundSet, +1, , mute
AutoHotkey takes a little time to get used to out of the gate, but once you've mastered it, you'll never want to use a computer without it again!


