Automation utilities are becoming increasingly popular, both on the desktop and on mobile platforms where apps like Tasker and IFTTT are now used by millions of people. On Windows, AutoHotKey has stood the test of time and remains one of the most popular scripting utilities that can be used for pretty much anything you can think of. Automation tools are notorious for being overly complex and unfriendly to newcomers so I will try to explain how AutoHotKey works so that everyone can understand.
Setting up AutoHotKey
After downloading the utility from the link above, run the installer and select the 32-bit option. Even if you have a 64-bit computer, the performance increase is not worth the fact that your scripts will not run in 32-bit systems. In the final screen, read all options carefully because they are checked by default and you may want to alter them before continuing. For instance, the last option will let you keep each AutoHotKey script running as a separate icon in the taskbar but you will not be able to pin the program as a result.
By far the easiest way to use AutoHotKey is to find scripts that other people have already created. Though we will also look at creating your own scripts, anything more advanced than custom hotkeys will require some familiarity with coding or at least the various parameters and general syntax of AutoHotKey. You can find scripts virtually anywhere including the official AutohotKey Script Showcase and the forums.
Now, scripts online come in two different variations. More advanced scripts come as .ahk files which is the format AutoHotKey uses. All you have to do in these cases is run the script like a standard executable file by double-clicking on it.
More basic scripts come in the form of simple text so you can create them manually. Take the script below as an example.
The only thing it does is turn the tilde/accent key into backspace so that I can delete highlighted text easier as I hold the mouse in the right hand. To save this script, copy the text and paste it into a text file. Then, click on File > Save As and save the script as an .ahk file. The extension is the only thing that matter so you can give whatever names you want to the files. With that said, you should select the “Unicode” option from the Encoding menu and the “All Files” option from the “Save as type” menu to make sure nothing goes wrong.
Any scripts that you run on your computer have individual icons in the system tray. Rolling your mouse over the icon will tell you which script each icon represents and right-clicking on them will provide a range of utilities, including the option to pause a script or reload it after making changes to it. The context menu options will differ depending on the script you are running as users can craft custom items for the menu.
Creating a script
Now that you basically know how to use AutoHotKey, it is time to learn how to create basic scripts as well. To start with, right-click on an empty area of your desktop (or anywhere in your PC) and select New > AutoHotKey Script. Then, right-click on the newly created file and select the “Edit Script” option. This will most likely open a Notepad window which is exactly what we want as this is where we will enter our code.
When you are trying to create a script, there is no better place to be than the official documentation page as it can provide answers to any question you might have. You will be able to find what commands you can write, what the various symbols mean, what the basic usage and syntax of AutoHotKey is and so much more. Even if you are not familiar with any of this, time is all you need because the information is already there.
Just so you can see what a basic script would look like, grab the following file and open it in editing mode. You will see that it contains this code:
This is a more advanced version of the script we saw above. What this does is replace the accent key with Backspace if you simply press it yet keeps its normal functions if you combine it with Shift or Ctrl respectively.
The “::” part tells the script that the first item, in this case “`”, should be replaced by the second item, in this case “Backspace”.
The “$” symbol is simply used to force the keyboard hook to be implemented for this hotkey in order to avoid conflicts and looping issues. It is necessary here because we used the Send command along with a combined hotkey, otherwise you can forget about it.
The “+” represents Shift and “^” represents Ctrl. As such, the above command specifies that when a user presses Ctrl + the Tilde key, the script will type out the accent symbol normally instead of replacing it with Backspace. The same goes for the next line where Shift + Tilde results in the tilde symbol instead.
The “Return” line is one you will see in every single script because it simply marks the ending of the script. If you actually get into AutoHotKey, the Return command will become second nature because no script works without it and it is always in the same place.
Compiling and sharing scripts
Though you may not need to do this for a while, it is good to know what you can do with crafted scripts after you are finished with them. When you are certain that a script is ready for use, you can use AutoHotKey’s included compiled to create an executable file that can run your script in any computer, even ones that do not have the application installed. The compiled scripts run like any other executable so it is like creating your very own program.
The easiest way to compile scripts is to right-click on an .ahk file and select the “Compile Script” option. A new executable file with AutoHotKey’s icon will be created on the same folder instantaneously. You can also run the “Convert .ahk to .exe” app from your Start menu in order to get more options like using a custom icon.
As a bonus tip, it is generally a good idea to bundle executable files inside ZIP or RAR archives if you are planning to share them with friends and family because many services refuse to accept transfers of .exe files.