AutoHotkey Tutorial: How to use AutoHotKey scripts to automate tasks

This is a beginners guide to create AutoHotkey scripts. AutoHotkey is a program that allows you to create a key combination for a task. You can call them macros or mini programs. The scripts or mini programs created using AutoHotKey have .AHK extension. The programming language is easy as you shall see in this mini tutorial for AutoHotKey.

autohotkey tutorial

AutoHotkey Tutorial

First of all, you have to download AutoHotKey and install it on your computer.Its program icon will sit in the system tray, from where you can control all your scripts. You can also suspend AutoHotkey from here for a period of time or even exit if you don’t need to run scripts. Please note that if you exit the system tray application, your scripts won’t function.

As you install AutoHotKey program, you get an option to see sample scripts in Notepad. It says SHOW README. If you keep the box checked and click Finish after installation, a Windows Help Window is launched where you can find detailed instructions on how to use the program.

IMPORTANT: Create scripts in Notepad and save them with .AHK extension so that they work. Select ALL FILES under Type (the second drop down list below Filename Text Box). It shows *.* in the related text box and there, you have to enter AHK instead of TXT. If you save as TXT, the script will not work.

How to use AutoHotkey scripts

The following is a brief tutorial for using AutoHotkey.


When you create scripts, you assign them to keys. In most cases you have to assign them to a combination of special keys followed by regular keys. The special keys in this regard are WINDOWS KEY, CTRL, SHIFT and ALT. You can use one or more than one special keys to assign your scripts. For example, you might want to assign a script to CTRL + SHIFT + S. In that case you have to type the special keys in the format provided by AutoHotKeys.

CTRL is represented by ^

SHIFT is represented by +

ALT is represented by !

Windows Key is represented by #

:: part ends the hotkey combination and script follows

To begin, you first have to type the special key combination that will activate the script you created. For example, if you wish to assign CTRL + SHIFT + S to launch Google, your script will look like the following:

^+S:: Run

Special Words or Commands

To launch a program or website, use RUN. For example if you create the following:

!^F:: Run Notepad

With the above script, when you press ALT+SHIFT+F, Notepad is launched. RUN is a keyword that helps you run a program or launch a website. Another example below shows you how a hotkey opens Google in your default program and then launches Notepad.

Run Notepad

All the four lines above are one script that is activated using CTRL+SHIFT+E. The word RETURN is another keyword that indicates end of script when you are using multiple lines. Whenever you create a script with more than one line, you should use RETURN at the end of the script so that AutoHotKey knows that the script ends here.

You can add as many commands you want into a single AHK file, but remember to use RETURN towards the end of last script in the AHK file. You have to launch the AHK file by double clicking it before you can use the scripts

Another keyword worth using is SEND. It sends keystrokes to the shell and you can use it create things like signatures etc. See the following example.

Send Regards{ENTER}Arun Kumar

In the above script, when I press CTRL+ALT+S, it will paste Regards, followed by an Enter key (for line change) and then insert Arun Kumar. The above example shows you how to enter the ENTER key. The ENTER key is always included inside braces {}.

Similarly, if you wish to enter a TAB, it should be {TAB}. Likewise, space key will be {SPACE}. You need not use {SPACE} to enter a SPACE. It will automatically take in SPACE when you enter SPACE key in the script as in the above example. In the example, Arun is followed by a SPACE and then Kumar.

This tutorial is not comprehensive but is enough to get you started with the program to create short AutoHotKey scripts.

Now read: Display global hotkeys list in Windows.

Posted by on , in Category General with Tags
Arun Kumar is a Microsoft MVP alumnus, obsessed with technology, especially the Internet. He deals with the multimedia content needs of training and corporate houses. Follow him on Twitter @PowercutIN