You've gotten the hang of email filters or keyboard shortcuts. You’re ready to start getting into some more advanced productivity hacks, but jumping into Python seems too intimidating. Fortunately, there’s a tool that’s robust enough for power users but accessible enough for everyone: AutoHotkey.
What Is AutoHotkey?
At its most basic level, AutoHotkey is a Windows application that lets users remap keys and create simple shortcuts. So, for example, you could put your Caps Lock key to better use by turning it into a mute button. This is especially useful if you use programs with complicated keyboard shortcuts. That one obscure Word function that’s assigned to Ctrl-Alt-Shift-\] would be a lot easier to use if it was just assigned to F3, wouldn’t it?
However, if you’re willing to learn some minor scripting, AutoHotkey can do a lot more than simply remapping buttons. It can launch applications, reformat text, or fill in long blocks of text with shorthand—for example automatically filling in “your@emailaddress.com” when you type “@me”.
Every AutoHotkey script can be written in a basic text editor, like Notepad. To run the scripts, make sure AutoHotkey is downloaded and installed. Write your script in a text editor (which we’ll show you how to do down below) and save it as an .ahk file. You can then run any of these scripts and pause or close them from the taskbar. Most of the time, AutoHotkey will run invisibly in the background, doing whatever you programmed it to do and otherwise staying out of the way.
How to Write AutoHotkey Scripts
Since Autohotkey is designed to be as accessible as possible, you don’t need to have a background in coding at all in order to know how to use it. For example, let’s say you keep accidentally hitting Caps Lock when you mean to hit Shift, and you’d like to remap it so both buttons are Shift keys. To do this, you would only need the following line:
Capslock::Shift
In this line, “::” remaps what’s on the left of it (in this case, Capslock) to whatever you put on the right (Shift). If you only want one key to act like another, this is the most complicated syntax you need to know. There’s a full list of key names here so you can customize this however you want. Of course, that’s just remapping one single button to another. What if you want to remap a combination of keys? For that, AutoHotkey uses prefix modifiers. These are symbols that correspond to modifier keys like Control (^), Shift (+), Alt (!), and the Windows key (#). When you use these symbols in a script, AutoHotkey expects a keyboard shortcut. So, for example, in this line: ^+!n::Capslock
The keyboard shortcut Ctrl-Shift-Alt-N would now be mapped to Capslock. Which you’re much less likely to accidentally hit. You can even put both of these lines—and as many other shortcuts as you like—in a single file. Beyond these basics, AutoHotkey comes with a library of commands that can do a lot more than just turning one key combo into another. For example, let’s say every day when you get to work, you open up the same website. Instead of opening your browser and typing in the address, you can use this line: ^!t::Run "www.wired.com"
The Run command can be used to launch external applications or, as is the case here, a web page. So, with this script, pressing Ctrl-Alt-T will automatically launch Wired.com. All with a single line of code!
AutoHotkey commands and scripting goes a lot deeper than most people probably need. However, you can find plenty of existing sample scripts out there that can do what you need without having to learn to code yourself.
Adjust the Volume and More
Basic commands and key remaps are easy with AutoHotkey, but if you want something more complex, you can still usually get by on what helpful developers across the internet have already done. The company even has its own Script Showcase where you can see featured scripts and get your own ideas.
To get you started, we’ve also included a few sample scripts below to give you an idea of the kinds of things you can do with AutoHotkey. Adjust your volume If your keyboard doesn’t already have volume keys, you can turn your function keys into volume controls with these commands: F10::Send {Volume_Up} F11::Send {Volume_Down} Mute your volume Building on the previous example, you can also turn one of your function keys into a mute button with a script like this: F12::Send {Volume_Mute} Always keep NumLock on Isn’t it annoying when you try to use your number pad, but you accidentally hit NumLock a few hours ago and now it isn’t working right? You can fix that by creating a script that forces NumLock to stay on all the time. This can also be used for ScrollLock or even CapsLock if you don’t want to repurpose those keys instead. SetNumlockState, AlwaysOn Build your own custom autocorrect Are you always mistyping sesquipedalian? Or do you just have a really long email address you have to type dozens of times a day? AutoHotkey can handle both with a concept called hotstrings. Pick a unique string of letters—and we mean really unique, you don’t want it showing up in the middle of a regular word—and have AutoHotkey replace it with the full text. This work a lot like regular hot keys, except that you place “::” on both sides of the text to replace, not just after it, like so: ::@me::myemail@address.com
AutoHotkey even has a massive autocorrect script to start with if you want to cover common misspellings that the apps you use don’t already fix. AutoHotkey can do a lot more than what we’ve shown here, but hopefully this gives you the basics and a foundation to explore further. The ideal use case for AutoHotkey is serving the highly specific need that only you really have, so take a look at your workflow and see what you can do with it.
By: Eric Ravenscraft is a freelance writer from Atlanta, covering tech, media, and culture for The New York Times, Medium, and more. WIRED.COM
Comments