TSolo315 MturkCrowd
Six years of turking experience

Writing Your First AutoHotkey Script

Learn how to write a simple AHK script

1

Create the AHK script file.


There are two simple ways to do this:

  • Right click your desktop or in a folder and choose New > AutoHotkey Script. You would then give the script a suitable name.
  • Open a new notepad file and save the file with the .ahk file extension. So you would open notepad, choose File > Save As, and then save the file as "yourtitlehere.ahk".
2

Open the script file for editing.


If your script it not yet open, right click the script file and click Edit Script.

3

With the script file open, start coding.


We will start with a very simple script. Copy the following into the script file:


^t::
SendInput This is my very first script
return

Script Breakdown: ^t:: is denoting the key you want to bind your macro to. In this case it is the key combination control + t. In AHK ^ stands for the control key. Sendinput is a command that tells AHK to send the following sequence of keys. In this case it will send "This is my very first script" Finally, the return command tells AHK that it has reached the end of the code for the current macro (AHK scripts can contain several hotkeys/macros in a single file and if you forget the return command AHK will immediately start running the next macro in the script without stopping -- which can wreak some havoc).

4

Double click your script file (outside of the editor) to start the script.


You may notice an AHK icon pop up in your system tray at the bottom right of your computer. When you edit a script you can right click this icon and choose "reload script" to activate any changes you have made since first running the script. If you don't reload the saved changes will have no effect.

5

Place your cursor somewhere text can be written and press the hotkey combination Control+T.


You should notice "This is my very first script" being written every time you use this hotkey. Congratulations, you have written your first AHK script!

Next Tutorial: AutoHotkey Basics