What is AutoHotKey and How To Use It to Automate Things in Windows

AutoHotKey is one of the best tools ever created to automate almost anything on your Windows machine with a single shortcut. While there are a lot of shortcuts in Windows to help ease your workload, they are not highly customizable and you cannot create new shortcuts as required. AutoHotKey allows you to create more complex actions and macros with the hot key combinations of your choice. Here is how you can install AutoHotKey and use it to automate things in your Windows system.

AutoHotKey is a free, lightweight and open source application which can be used in tons of ways like binding keys, customizing your computer, data manipulation with regular expressions, complex macros, compiling scripts, etc. Since AutoHotKey is mainly intended for power users, it uses scripts written in a specific syntax to perform all those magical actions. Simply put, AutoHotKey can run any action with a single keystroke. It is more than just a regular key binding application.

Note: due to the deep interactions between AutoHotKey and your operating system, some antivirus software may flag it for virus. You can safely disregard those warnings as they are nothing more than false positives.

Before getting started, don’t get intimidated by the words “Power User” and “Scripts” as AutoHotKey is really easy to work with once you get used to it. You can download it from its official website and install it like any other software. Once installed, launch the application from the Start menu.

autohotkey-installation

Once you’ve launched the application, AutoHotKey will display a window asking whether would you like to see a sample script. Simply click on the “Yes” button to see the sample script.

autohotkey-getting-started

This action will open the sample script in Windows Notepad application. As you can see, AutoHotKey has already created a couple of shortcuts which are mapped to open AutoHotKey’s website and a new Notepad window when pressed.

autohotkey-sample-script

To test it out, navigate to the “Documents” folder and execute the file “AutoHotkey.ahk” by double clicking on it. Now press the shortcut “Win + Z” to open the AutoHotKey website in your default browser and “Ctrl + Alt + N” to open a new Notepad window.

autohotkey-execute-sample-script

Now let us create a basic script to get you started. Open your Notepad application and copy and paste the below code into it. Now save it as “shortcuts.ahk,” paying attention to the extension.

; Shortcut to open calculator app
^+s::Run calc.exe
return

If you break down the script, the first line is nothing but a comment. The second-line tells AutoHotKey that whenever you press Ctrl (^) + Shift (+) + S to run the application “calc.exe” (calculator). And the third line is nothing but you telling AutoHotKey that the statement has ended.

autohotkey-calc-script

Now right click on the saved file and select the option “Run Script” to execute the script. Press “Ctrl + Shift + S” and you will have your Calculator application opened.

autohotkey-run-script

With AutoHotKey, you can also create custom messages which appear whenever the user presses a certain combination. For instance, copy the below script and run it.

;Simple message box
^Numpad0::MsgBox You pressed number zero while holding ctrl.
return

From now on, whenever you press “Ctrl + NumberPad 0,” the pre-configured custom message will be displayed. Of course, you can make it even more complex like a message being displayed whenever you open or close a certain application, etc.

autohotkey-msg-displayed

Besides running programs and displaying custom messages, you can also remap your keyboard keys. This way, you can put to use your least used keys like insert, scroll lock, etc., on your keyboard. For instance, the simple script below will remap the “Tilde” key on your keyboard to act as “BackSpace.” This is particularly helpful for those who write a lot.

;Replace Tilde with BackSpace
`::BackSpace
return

autohotkey-replace-keys

If you ever want to suspend the shortcuts temporarily, simple right click on the taskbar icon and select the option “Suspend Hotkeys.” If you want to completely exit the script, just select the “Exit” option.

autohotkey-suspend-keys

That’s all there is to do, and the things we discussed here are just a bit of what AutoHotKey can do. If you can learn the AutoHotKey syntax, you can do a lot more interesting things tailored for your specific needs. You can also create even more complex scripts that can really automate a lot of your daily routines saving you a lot of time in the process.

Hopefully that helps, and do comment below sharing your thoughts and experiences on using AutoHotKey.