Misc

AutoHotkey Tutorial How to use AutoHotKey scripts to automate tasks

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

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.

Special Keys (CTRL, ALT, SHIFT, WINDOWS KEY)

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 google.com

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.

^+E:: Run google.com Run Notepad Return

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.

^!S:: Send RegardsENTERArun Kumar Return

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.

Control & manage mouse movement between multiple monitors in Windows 10
Dual Display Mouse Manager lets you control & configure mouse movement between multiple monitors, by slowing down its movements near the border. Windo...
WinMouse lets you customize & improve mouse pointer movement on Windows PC
If you want to improve the default functions of your mouse pointer use freeware WinMouse. It adds more features to help you get the most out of your h...
Mouse left-click button not working on Windows 10
If you are using a dedicated mouse with your laptop, or desktop computer but the mouse left-click button is not working on Windows 10/8/7 for some rea...