- 1. Introduction
- a. Installing AutoHotkey
- b. How it works
- c. Examples
- 2. Making our first simple macro-shortcut.
- a. The .ahk file
- b. The “language”
- c. Replace a set of words/characters
- d. Turning our CapsLock into an extra modifier
- i. Why the CapsLock key?
- e. Make complex shortcuts out of simpler ones
1. Introduction
So... AutoHotKey! You may not like it, but this is what peak productivity looks like. With AutoHotKey, we will be able to program out own shortcuts and macros, and become best friends with out keyboards and our PC’s.
-But, Rolando, I don’t know how to program!
Well, don’t worry! It might sound scary at first, but in this Intro to AutoHotKey I will touch on some very simple actions and increasingly up the level of complexity. By the end of this guide I hope I will have piqued your interest enough to want to try your own macros and shortcuts.
a. Installing AutoHotkey
You can install AutoHotkey (AHK) following this link. It is only available for Windows OS.
b. How it works
Essentially, AutoHotkey is a program that will listen to inputs from your keyboard -every time you press a key or combination of keys- and then go through a script/file that we’ve written and output the same keys or different keys, depending on what we tell it to do.
The application comes as an .exe that needs to be installed, and once installed it reads a file type ending in .ahk. In this file we will write (with any text editor we like) our code for AHK to execute.
When you double-click an .ahk file, it will show up as a small green icon with an “h” on it. You can right click it to reload, quit, edit, etc...
On a basic level, we can tell AutoHotKey every time I press “a” on my keyboard, type “b” instead. The fun thing is, we’re not limited to just letters. You could tell AutoHotKey to perform very complicated actions based on very simple inputs. Let’s look at some examples.
c. Examples
Let’s look at some examples of what can be done, going from very simple to fairly complex.
- Expand words and sentences (writing be right back whenever you write “brb”)
- Change inputs (Assigning F1, F2, F3... or any keys to things like Middle Mouse Click, Play, Pause, Sleep...)
- Use a combination of keys to launch any program (Ctrl+Alt+C to open Calculator, Notepad, or any other program for example)
- Turn any key into a modifier. A modifier is a key like Ctrl, Alt, Shift, or Fn, that basically alters the behavior of another key when it’s pressed in combination with it. We all know if you press the “b” key, you will output a “b”. But if you hold Ctrl and press “b”, it modifies the behavior of the b key. I particularly use this to turn my CapsLock key into an extra modifier of sorts, and this way I don’t interfere with other default key shortcuts.
- Use a combination of keys to open folders (I use CapsLock + 1, 2, 3, 4... to open different folders from anywhere that I use regularly).
- Use a simple combination of keys to run more complicated shortcuts (I use the CapsLock key in combination with other letters to execute more complicated shortcuts that I can then assign inside my other softwares. For example, I press CapsLock + B, and AHK outputs “Shift+Ctrl+Alt+B”. By making these complex shortcuts I make sure that they don’t interfere with other default shortcuts in any apps, and I have an entire keyboard’s worth of combinations).
- Create multiple step macros. (Any combination of keys to perform several steps like, for example Open Notepad → Type a string of words → Save → Close notepad). We can also se the timing for these actions, to the point where they could happen in just half a second if we want to.
- Apply macros or shortcuts depending on which window is active. AHK can tell which window you’ve currently selected and apply one set of macros or another. This is also useful if you want your macros to only apply to a specific program.
- Look for specific information from our screen and perform actions based on that information. Essentially, AHK can also read our mouse position, or any specific color on a portion of our screen, and store that information as variables to access later. For example, I can press a combination of keys that will read where my mouse is, “Original Position”, then move it to a specific place in the screen, perform an action, and then bring back the mouse to the “Original Position”. Since a lot of these macros happen in fractions of a second, you might not even know your mouse moved to perform an action elsewhere!
Those are a few examples off the top of my head, many of which I’m currently using. If this feels overwhelming or you’re not entirely convinced, I recommend you still give it a chance and keep going. It will be very worth it once you’re set up with a few shortcuts
2. Making our first simple macro-shortcut.
There is a plethora of things you can do in AHK. If you’re into it, I recommend going over the documentation on their website and reading on the kinds of things AHK can read and execute. It’s never-ending, and it might even give you some very cool ideas. For this intro, we’re going to focus on some of the simpler ones and build on it gradually.
a. The .ahk file
b. The “language”
c. Replace a set of words/characters
d. Turning our CapsLock into an extra modifier
This one is a bit ahead in terms of complexity, but I feel like it’s necessary to take care of this one first, because it really opens the way to actually customising your own macros without worrying about interfering with any other apps. Essentially, we’re turning the CapsLock key into another kind of “Alt” or “Ctrl” key, that can be used in combination with any other key to activate macros and perform actions with AHK.
i. Why the CapsLock key?
I choose to use the CapsLock key as an extra modifier because, out of all other keys, it’s the one I use the least. Personally, IF I EVER WANT TO WRITE IN CAPS, I’ll just hold shift. That’s almost never the case, so instead I decided to give my CapsLock key some good use. It’s also very well placed to use in combination with any other key in the keyboard. In theory, you can use any key as a modifier. In this tutorial I will be using CapsLock as I feel it works best, and gives us the most functionality while losing the least functionality. For other people who have custom-made macro keyboards, there are a couple of other extra keys that might also be well suited for this.