August 27, 2008

Program Your Own Keyboard Shortcuts

We'll show you how to save time, keystrokes, and mouseclicks by making your own customized shortcuts.

Pressing buttons isn't particularly good for you. Jane Jetson knew it as early as 1962, and your friendly neighborhood orthopedic surgeon would be hard-pressed to argue with her today. Problem is, you can't very well answer your daily deluge of e-mails without typing, and as if to add insult to injury, odds are you're pretty much typing the same thing again and again.

One approach is the macro: a tiny program you write (or have generated automatically) that can lift the burden of repetitive tasks—like typing email replies—by doing them for you. Macros have been around for decades, but there's usually a catch that makes then not worth the trouble. You can write a macro in Word or Excel, but you can't use it outside (nor inside Office in some cases, depending on your antivirus settings). Windows includes the Script Host, but it's hard to use, and it's lousy at controlling programs and typing text. But a small, free download called AutoHotKey takes a different tack—one that, as it turns out, might actually save you some time.

AutoHotKey has no interface to speak of; you use only a plain text editor (for example, Notepad) to write your scripts, and then save them with the AHK filename extension. But since AHK files are more configuration files than procedural scripts, you can double-click an AHK file right away to load it and leave it running in the background while you work on other things. Then when you press one of the hotkey (or "hotstring") combinations defined by the AHK file in memory, AutoHotKey does the rest.

Each line in your AHK script identifies a trigger and an associated action. For instance, the one-line script in Figure 1 opens Google's search page in your default browser whenever you press the Windows logo key + G. (Here, the # character represents the Windows logo key, and the double colon :: separates the hotkey from the commands to carry out when the key combination is pressed.) But that's AutoHotKey at its simplest.

Global Autocorrect

Are your annoying texting habits creeping into other parts of your life? Use AutoHotKey hotstrings (Figure 2) to automatically expand abbreviations as you type, no matter what program you're using. Here, the double-colon mark goes before and after the abbreviation.

Without changing the way you type, "btw" instantaneously becomes "By the way," "fubar" becomes "[fouled] up beyond all recognition," and "kissoff" becomes "Thank you for your suggestion; it has been forwarded to the appropriate department for review." AutoHotKey is even smart enough to ignore incidental abbreviations buried in other words, so "atmosphere" doesn't become "at the momentosphere."

You Can Do Anything—but Seek Help First

You can also carry out a sequence of commands from a single hotkey, as long as you end the sequence with the "return" keyword (Figure 3). The flexible (albeit sometimes confusing) scripting language lets you simulate mouse clicks, read and write text files, display balloon-tip messages, override Windows' default keystroke combinations, control speaker volume, change the opacity/transparency of windows, and more. You can even "compile" your scripts into standalone EXE files and then run them on other PCs without having to install the full AutoHotKey package. Nearly everyone will need to peruse the enormous help file to accomplish any of this, however. AutoHotKey also has an active forum that provides, among other things, sample scripts and community support.

What AutoHotKey lacks, though, is context awareness. If you want to personalize a canned email reply spit out by an AutoHotKey script, you'll have to do it by hand. But here's a tip: If you need a more personalized touch and you happen to use Mozilla Thunderbird, try the QuickText extension (extensions.hesslow.se/extension/4/Quicktext/), which can grab names and other cues from your outgoing message and use them in your reply. So, instead of "Dear Customer," your canned response could automatically begin, "Dear Miss Teschmacher."


The beauty of AutoHotKey, though, is that it can be used anywhere. If you're able to use the same shortcuts in Gmail, Excel, Photoshop, and World of Warcraft, it might finally be worth your time to write a macro or two.


0 comments:

Post a Comment