AutoHotkey could change your computing life. The freeware Windows 10 program allows you to write your own keyboard shortcuts for any program you use (or for Windows in general), taking even multi-step tasks that would require a lot of typing and mouse movement and turning them into one key combos. One could write a book on how to use all the advanced features of Autohotkey’s scripting language, but to get you started, we’ll provide a few basics. Below we show how to create a very simple keyboard shortcut that launches a website, build a “hotstring” that turns a short keyword into your entire email signature and a write a hotkey that that selects an item from a pulldown menu in Photoshop Elements, allowing you to crop with a single key stroke.
Before You Begin: Install AutoHotKey
Before you create an AutoHotKey Script, you need to download both the program itself and its editor.
- Navigate to http://autohotkey.com, click Download and install the AutoHotKey app.
- Also download and install SciTE4AutoHotkey. You’ll use it as a text editor for creating shortcuts.
Creating a Simple Hotkey Script
You’ll need to create and store all of your shortcuts in a single AutoHotkey File, which is simply a text file with the extension .ahk. You need your AutoHotkey file running in the background when at all times, if you want to use its shortcuts. We therefore recommend that you save the file in your Startup folder, which is usually located at C:\Users[USERNAME]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup. While you can edit your .ahk file in any text editor, including Windows Notepad, we recommend using SCiTE4AutoHotkey, which you downloaded above, because it auto suggests AutoHotkey commands and lets you run your scripts just by hitting the F5 key. Let’s make a very simple script that launches a website from anywhere in Windows, just by hitting a keyboard combo.
- Open SCiTE4AutoHotkey. You should see a blank document.
- Hit CTRL + N to create a new document if the program doesn’t already have a blank document open.
- Type ^!m:: on the first line and hit Enter. This signifies the hot key CTRL + ALT + m. For each hotkey you create, you must put a series of symbols which represent modifier keys (CTRL, ALT, Windows Key, etc), then a primary key (a,b,c,d, etc) and then two colons (::) as a delimiter.
- Type Run, http://www.gmail.com on the second line. This is a command that tells the computer to “run” the gmail URL. It will launch that URL in your default browser (ex: Chrome, IE, Firefox). Note that “Run” is just one of hundreds of Autohotkey commands. In AutoHotkey, Each line of code is terminated by a line break, unlike in many other programming and scripting languages that end their lines with a semicolon (;).
- Type Return on the third line. The word Return signifies that the shortcut code has ended. Then you can put other keyboard shortcuts below, within the same .ahk file.
- Save your .ahk file. We recommend saving it to the Windows Start folder so that it runs in the background every time you start your computer. The Windows Start folder is usually located at C:\Users[USERNAME]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup. Hit CTRL + S to get the save menu. Here, we’ll name our file myhotkeys.ahk.
- Hit F5 to run your script. You’ll see a notice at the bottom of the SCiTE4Hotkey screen that shows your script is running. If there are any syntax errors in your script, you’ll get an error message in red.
- Test your keyboard shortcut. It should work! In this case, hitting CTRL+ALT+M will load Gmail in your primary browser.
- Select Stop Executing from the Tools Menu (or hit CTRL + Break) to terminate your script. You’ll want to terminate your script and restart it (F5) every time you make changes.
Creating a Hotstring to Autocomplete Text
With AutoHotkey, you can also create what’s called a “hotstring,” a short set amount of text that automatically turns into a larger piece of text (or even executes commands). Imagine if you could just type the text “mysig” into any program and have it automatically convert into your entire email signature. Here’s how to create a simple hotstring that does just that, by adding to your .ahk file.
- Enter the hotstring, surrounded by two colons (::) on either side, when editing your macro file in SciTE4AutoHotkey. In this example, we’ll make it ::mysig::.
- Type the autocomplete text directly after the final colon, without using a linebreak. Use the symbol
r to signify a carriage return and
n to signify a double return. - Enter Return on a separate line. Now, when you type the text “mysig” and hit the spacebar in any program, whether it’s Microsoft Word or a web form, you’ll get the signature text.
Creating a Hotkey for a Menu Item
Perhaps the best use of a custom keyboard shortcut is for selecting an important and frequently-used action from a menu. For example, to crop an image in Adobe Photoshop Elements, you have to go all the way up to the top navigation and select “Crop” from a pulldown menu. However, if you’re constantly cropping images, you’re wasting time and straining your shoulder by poking the mouse or touchpad. Here’s how you can create a keyboard shortcut for a menu item in any program. 1. Open Active Window Info (Window Spy). It’s a small utility the AutoHotkey installer adds to your system when you first use it. Window Spy helps you learn the names of different windows and sections of windows so you can use them in your AutoHotkey script. 2. Open the app you want to write the shortcut for (ex: Photoshop Elements). 3. Hover your mouse over the pulldown menu you wish to access (ex: Image). 4. Hit Windows Key + A to freeze Window Spy’s display so that it doesn’t’ change. 5 .Take note of the Window class, which is usually written as ahk_class [class] in the Window, Title, Class and Process section. With Photoshop Elements, this is ahk_class pseeditor. 6. Enter #IfWinActive ahk_class pseeditor (or the current class name for your app) on a new line in your .ahk macro file. This line shows ensures that your keyboard macro only activates if the Photoshop Elements window is active. 7. Enter your keyboard shortcut on the next line. Make sure whatever key combination you choose is not already in-use in the program. We’ll use ^;:: (CTRL + ;) in this case because it’s available. 8. Take note of the “Client” coordinates (ex: 152, 23). 10. Open the pulldown and note the placement of your action item, crop. It is three steps down, which means that a user could activate it by hitting the down arrow on the keyboard three times and then hitting Enter. 11. Type Send {Down 3}{Enter} onto the next line. This tells the script to send three down arrow presses and one Enter press. To see a list of all keys you can send, check out AutoHotkey’s reference page. Special keys like Down Arrow and Enter have brackets around them but regular letters do not. 12. Type Return on the next line. Your script is now complete. There are other ways to write a script like this. For example, you could choose to send the letter P rather than three down arrows because, in Photoshop Elements, the letter P would jump you down to Crop. Depending on the program you choose and its menu structure, you may find that sending different key presses or mouse clicks is most effective.
Sharing Your Keyboard Shortcut File
If you want to share your AutoHotkey keyboard shortcut file with a friend, you have two choices:
Send them the .ahk file (ex: myhotkeys.ahk) and make sure they install AutoHotkey so they can run it. However, not everyone wants to install a separate app.Compile your .ahk file into an .exe, which anyone can run on its own.
To compile your keyboard shortcut file, simply select Compile from the Tools menu. An .exe version of the file (ex: myhotkeys.exe) will appear in the same directory as your .ahk file. Tell your friend to put the .exe file (or the .ahk file if you choose that route) in the Windows Startup folder. That’s usually C:\Users[username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.
Customize Windows 10
Previous TipNext Tip
Create Custom Keyboard ShortcutsMake Windows 10 Look and Feel Like Windows 7Change the Default Windows FontTurn Off Notification and System SoundsChange Your Desktop Background in Windows 10Change the Icon SizeGive Windows 10 a Dark ThemeMake Your Own Windows 10 ThemeHide Your Name on the Login ScreenAdd Another Column to the Start MenuGet Mac-Like File PreviewsAdd My Computer Icon to DesktopEdit Photos to Fit as BackgroundsAdd Accent ColorsCustomize Autoplay MenuInstall and Delete FontsCustomize the Action CenterDisable Transparency EffectsGet Classic Solitaire and MinesweeperChange the Look of Windows 10 BooksAdd a URL Field to the TaskbarAdd Clocks from Multiple Time ZonesGet the Old Volume Control BackDisable Windows 10 Startup DelayAdd Quick Contacts to the Start MenuShow Hidden Files and FoldersEnable Spatial SoundBest ThemesAll Windows 10 TipsChange the Login Screen BackgroundInstall New Desktop Themes