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.
What is AutoHotKey and How To Use it to Automate Things in Windows
US software giant Microsoft pre-installed Windows 8.1 personal computers and tablets are displayed at a Windows 8.1 launching event in Tokyo on Oct. 18, 2013. (Yoshikazu Tsuno/AFP/Getty Images)
1/19/2015
Updated:
1/19/2015

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.

What is AutoHotKey

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.

Installation and Usage

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. 

(MakeTechEasier)
(MakeTechEasier)

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.

(MakeTechEasier)
(MakeTechEasier)

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.

(MakeTechEasier)
(MakeTechEasier)

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.

(MakeTechEasier)
(MakeTechEasier)

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.

(MakeTechEasier)
(MakeTechEasier)

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.

(MakeTechEasier)
(MakeTechEasier)

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.

(MakeTechEasier)
(MakeTechEasier)

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
(MakeTechEasier)
(MakeTechEasier)

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.

(MakeTechEasier)
(MakeTechEasier)

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.

Republished with permission from MakeTechEasierRead the original