How to Setup Your Windows Global Hotkeys in 10 Minutes

Image for postimage by Pexels

Setting up custom keyboard hotkeys is one of the things that saves us a lot of time every day. Not only that, but it makes working with a computer more fun because you feel in control.

Imagine that every time you needed to launch your favorite app or website, you do it with the push of a single button. No browsing folders, no icon clicking, no address typing. Push a button and you are exactly where you want to be. Pretty cool right?

Cool, but setting up the hotkeys and remembering them in the first place is tedious. Plus, there is no easy way to synchronize them between your devices. So if your machine dies or you decide to work from a different computer, it?s as if you haven?t set up hotkeys at all.

I was struggling for years to find a good software to meet all these needs:

  • Easy setup and installation
  • Easy change and remapping of hotkeys
  • Easy backup and synchronization between devices
  • Flexibility to use all keys and key combinations

I finally found a great solution that fulfills all of the above: AutoHotkey.

NOTE: You don?t need any coding knowledge to follow this guide, but you need to know some basics like creating a text file, changing a file extension, and basic software installation.

Global vs Local Hotkeys

Before we go into details, let?s define global and local hotkeys.

A global hotkey is a combination of keyboard buttons that execute a command in any application or window, like launching your calculator app for example. It doesn?t matter if you?re in Word, Excel, in a browser, or on the desktop. Pressing that keyboard combination will execute the command just the same and launch the calculator wherever you are.

A good example of global hotkeys are the custom play, pause, stop, and mute media buttons on some fancy keyboards.

Image for post

No matter which application you are in, these hotkeys will work just the same. The downside of those extra physical buttons is that they have a single function and they?re not easily remappable.

Local hotkeys, on the other hand, are application specific. They work only in specific applications, and only if the application is open and in focus. For example, Ctrl + T will open up a new tab in Chrome, but in Word, it will do something totally different.

Since most applications offer enough customization for their local hotkeys, we?re not going to focus on those. Instead, let?s look at how to create and customize the global ones.

AutoHotkey

Autohotkey is a scripting language, which is a simplified programming language that allows people that are not programmers to be able to use it.

For the non-tech savvy folks, it might be intimidating at first. It looks like you have to be a coder to be able to understand anything. But if you get the right template file and learn what the basic symbols mean, it takes just 10 minutes to set up your hotkeys and you?re good to go.

You need just 3 steps to get started:

  1. Download and install AutoHotkey
  2. Download the template .ahk file and customize your hotkeys (find the template file below)
  3. Start the .ahk file and put it in the Windows startup directory (so it automatically launches after each restart)

Do just these 3 steps and you?re done. Let?s go through each of them in detail.

Setting Up And Customizing Your Own Hotkeys

The installation of the software is just like any other, there?s nothing special worth mentioning in this guide. After you download it from the link above and install it, you?ll be able to launch all AutoHotkey files (.ahk).

So to begin with, let?s create the template file, that we?re going to use as a base to customize your own hotkeys. All you need to do is to copy the code below and paste it into a text file.

^+!1:: ;ChromeRun C:Program Files (x86)GoogleChromeApplicationchrome.exeReturn^+!3:: ;FirefoxRun C:Program Files (x86)Mozilla Firefoxfirefox.exeReturn^+!5:: ;SkypeRun C:Program Files (x86)SkypePhoneSkype.exeReturn^+!Q:: ;WinampRun C:Program Files (x86)Winampwinamp.exeReturn^+!W:: ;WordRun C:Program FilesMicrosoft OfficeOffice16WINWORD.EXEReturn^+!E:: ;EvernoteRun C:Program Files (x86)EvernoteEvernote.exeReturn

As you can see I?ve used common applications like Chrome, Skype, and Evernote as an example. Of course, you can delete and replace those with as many of your own applications or websites as you like.

Again, the code above probably looks daunting to you if it?s the first time you see AutoHotkey. So let?s use some color coding below to explain what each component means and how we can customize the hotkey for each application.

Image for post

There are just 3 parts for each application that you have to be concerned with:

  1. Hotkey ? the very first 5 characters for each application (e.g. ^+!1 and ^+!F). This is the key combination that is going to start your app.
  2. Comment ? the comment is the text highlighted in green (e.g. ;Facebook and ;Word). This is just a label to tell you what the paragraph is about.
  3. Application path ? the line after the blue keyword ?run? (e.g. C:Program Files (x86)EvernoteEvernote.exe)

Hotkey

The hotkeys are the combination of keys that are going to trigger a specific command, in this case launching an application or website.

In most hotkey combinations we use the modifier keys in the keyboard ? alt, shift, and control. It?s exactly the same way in this setup, but instead of alt, shift, and control AutoHotkey uses characters like !, +, and ^ to describe those in the code. Here is how they?re mapped out:

! = alt+ = shift^ = ctrl

The symbols are used for brevity, just so we don?t have to type the whole word every time, similar to how we sometimes use ?&? instead of ?and? in English. So if we wanted to use the key combination alt+shift+H, here?s how the code would look like:

!+H::

The double colon at the end means that the hotkey part is over and another part of the code begins.

You?ll notice that all of the examples in the template file above use all the modifier keys ^+!. In my setup I use all three deliberately to avoid overlap with local hotkeys that already exist in an open app.

For example, if Word was open and I used Ctrl+B as a global hotkey, besides launching an application the hotkey would also make the selected text bold in Word. Very few applications use all 3 modifiers for local hotkeys so using that setup you won?t have the overlapping issue.

Comments

The comments in the code, the green highlighted part, are just a label. They?re used so we can easily see which hotkey the paragraph is about. They do not have any effect when executing the code, so you can write anything you want after the ; character. It?s just for you and the person reading the code.

Application Path

After each comment follows the command that AutoHotkey executes. In this case, the command is ?Run? which is marked in blue. The command simply means that AutoHotkey will start an application after we press the key. We just need to provide the path to the application after the keyword ?Run?.

Most Windows applications will be installed in the ?Program Files? directory by default. All you need to do is to go into the specific application directory and find the .exe file. In the code above, you can see a few of the paths for common applications like Skype, Word, and Chrome.

Launching Websites

If you want to use the hotkeys for launching a website instead of an application, all you need to do is provide the code for the browser you?re using, followed by the website address you want to launch.

In this example, pressing Ctrl+Shift+Alt+F will open Facebook in the Chrome browser:

^+!F:: ;FacebookRun C:Program Files (x86)GoogleChromeApplicationchrome.exe facebook.comReturn

Return

Put a return keyword at the end of each paragraph to make sure you end the command there. If you didn?t put a return keyword, AutoHotkey will continue reading the code and run not only Facebook but all the other applications below it.

Creating your AutoHotkey File

After you?re done editing and customizing your hotkeys and applications, we have to save the text into an AutoHotkey file. You can do that by saving it with an .ahk extension like the example below.

Image for post

After you save the file, you can double click to launch it. It will show up as a tray icon on your toolbar, next to the clock.

Image for post

If you can see the green ?H? it means the script is running and you can work with the global hotkeys that we just set up. Give it a shot.

It?s very likely that you?ll get an error in the first couple of tries, especially if it?s your first time setting it up. Don?t panic, it?s most likely because of a typo in the code. Open the .ahk file again in a text editor and check carefully all the symbols and keywords.

Synchronization Between Devices

When our hotkeys are set up and ready to go, we want to make sure they?re identical on all our Windows machines. The best way to do that is to use your favorite cloud software like Dropbox, Google Drive, or Microsoft OneDrive.

For this to work, you need to have the cloud software installed on the computer and automatically synchronizing a folder, not just using it in a browser.

Put the .ahk file in the folder that is synchronized, so every time you make a change to the file it will be reflected on all your computers.

Running Your AutoHotkey File On Startup

Now that we have the same identical file on our machines, we want to make sure it launches every time the computer is restarted. To do that we have to put a shortcut of it in the windows startup folder.

Image for post

You can make a shortcut of it by right clicking on the file and selecting the ?create shortcut? option.

Then open the startup folder with the ?Run? window by pressing Windows key+R (or typing Run in the start menu). When the Run window starts just type ?shell:startup? and hit enter, like the example below.

Image for post

Copy and paste the shortcut in the startup folder and restart your computer to make sure it?s working.

Mapping Out Your Hotkeys Visually

Mapping out 3 or 4 applications on a keyboard is easy to remember. But what if you?re a power user and want to map out your entire keyboard? It gets tricky to remember all the keys and which applications they launch. That?s why mapping it out visually is very helpful.

Before creating any of the keys in my AutoHotkey file, I created a simple Photoshop file to assign applications to keys visually. Here?s how it looks:

Image for post

In the layout above you?ll notice that the modifier buttons ctrl, alt, and shift are highlighted to show the key combination for this layout. You can create as many layouts as you want for the key combinations that are convenient for you, like holding the Win key for example.

Feel free to use the base file below to create your own visual layout:

Image for post

AutoHotkey for Power Users

Setting up hotkeys is actually a tiny part of the functionality of AutoHotkey. If you?re a power user and you?re willing to fiddle with it, you can create wonders. Here are some functions that I often use with AutoHotkey custom scripts:

  • Turn the selected text into lowercase or UPPERCASE
  • Display the number of characters or words in the selected text
  • Paste the selected text without formatting
  • Set the volume to 20, 40, 60, 80, or 100% using the Win+Shift+1, 2, 3, 4, 5 keys respectively
  • Increase or Decrease the volume using the Win+Shift+Mouse Scroll Up/Down
  • Swap local hotkeys in specific applications (e.g. F5 does the function of F9 and vice versa)

Setting up something like that up does require more time and learning, but it?s well worth it and the principle is the same ? assign a hotkey to a command and run it with one click.

AutoHotkey has a great reference page and a great forum community that you can learn from. A lot of the scripts are already created for you so you can just copy/paste them into your own .ahk file and you?re ready to go.

Originally published at georgehalachev.com on August 8, 2017.

15