This article shows you how to use Autohotkey, and how to write basic scripts for it.
Introduction
Autohotkey is a free mouse and keyboard macro program which can do almost everything. I use it all the time, when I’m gaming and I even used it to help me type up this document. How, you ask? We’ll get to that later. Let’s start at the very beginning.
Step 1 – Downloading and Installing Autohotkey
First, go to this website and download Autohotkey. Install it, and run it.
Step 2 – Writing Basic Scripts – Part 1
Let’s start simple. We are going to write a basic script. First we will define the keystroke to use to start the action. We will then define the action which occurs when the keystroke is detected.
Right click on your desktop (or in the folder of your choice), and click New -> Autohotkey Script. Name it anything that you want. Then open it in your favorite text editor – I’m going to use PsPad.
To start your script writing, delete everything currently in the document. If you wish, you can edit the version, language, author and platform, but it is unnecessary, as all of those lines are commented (they have a ; (semi-colon) in front of them). If a line is commented, it means it will not affect how the script runs. People use comments to point out things to an editor of their code, and to also remind themselves of what each bit of code does.
In the script, start with something along the lines of this:
^!w::
The ^ (up arrow) means Ctrl, the ! (exclamation mark) means Alt, and the w means w. Also, The windows key (#) and Shift (+) can be added here. The double colon (::) defines the set of keys before it to be the hotkey to start the script.
So, ^!w:: means that pressing Ctrl + Alt + w all at the same time will start the script.
Step 3 – Writing Basic Scripts – Part 2
After we have defined the hotkey, there are many different commands that we can enter. Four of these are:
- Send – This can send keystrokes.
- Wait – This makes the program wait before commands.
- Run – This can run applications or files.
- MsgBox – This makes a message box pop up on your screen.
We are going to use the command “send”. After the send command is typed, we need to add a comma (,) and a space ( ). So, to what we already had, now add (on a new line) “Send, ” (without the quotes).
^!w::
Send,
Now, we want the script to send some keystrokes. The same form of abbreviation applies here, just like in Step 2 of the article.
Ctrl ^
Alt !
Shift +
Windows Key #
Also, {enter} can be used here to send the enter keystroke.
Let’s make it say Hello World.
^!w::
Send, Hello World
Step 4 – Writing Basic Scripts – Part 3
To finish off this script, we are required to end it with ‘return’. This means that you will be able to use the script over and over again. If you didn’t enter ‘return’ at the end, you would only be able to use the script once. You would then have to reset the program to do it again.
So, our Hello World script is finished!
^!w::
Send, Hello World
return
Step 5 – Running Your New Script
Save your newly made script. Make sure that its file extension is ‘.ahk’. ‘.ahk’ is the native file extension of Autohotkey; it is what is added to all Autohotkey scripts. Now, double click on the script to run it. You should see a little H icon in your system tray. When your script is running, every time you press CTRL + ALT + W, it will type out ‘Hello World’ for you.










One Response
I guess I forgot to mention how I used autohotkey to make the article. Well, I have an autohotkey script which is like a dictionary on a phone. It helps to complete most words.