In this instructable, you will learn how to use autohotkey and how to make basic scripts.

Step 1: Downloading and Installing Autohotkey

First, you are required to go to here and download Autohotkey. Install it and start it up.

Step 2: Lets Learn How to Write Scripts! - Step 1

We are just going to do basic scripts, where we define a key or set of keys which we are going to press and then the action.
Right click on your desktop, and click New -> Autohotkey Script. Name it anything you want, and open it in your favorite text editor. I'm going to use notepad.
First, delete everything that is there. Feel free to edit the version, language, platform and author if you wish, but it is unnecessary.

In the script, we will start with something along the lines of this:
The up arrow means Ctrl, the ! means Alt and the w means w. Also, the windows key (#) and Shift (+) can be added here. The double colon (::) after the hotkey defines the set of keys to be the hotkey to start the script.
means that the hotkey for this script is going to be Ctrl-Alt-W.

Now, onto the next step.

Step 3: Lets Learn How to Write Scripts! - Step 2

Ok, so we have defined the hotkey, we have to tell it to do something when it is pressed. So far we have:
There are many different commands that we can enter. Four simple ones are:
Send - which can send keystrokes,
Wait - which makes the program wait before commands
Run - which can run applications or files
MsgBox - which makes a message box pop up on your screen

We are going to use the command send. After we type a command, we always add a comma (,) and then a space after it. So, to add to what we already have I will add "Send, ".
Now, obviously we want it to send some keystrokes. The same form of shortening applies here, just like with the hotkeys used in step 2 of the 'ible.
Ctrl (up arrow)
Alt !
Shift +
Also {enter} can be used to make the 'enter' keystroke.

Lets make it say hello world!
^!w::Send, Hello World!
Now, lets move onto the next step to learn how to finish off a script.

Step 4: Lets Learn How to Write Scripts! - Step 3

Ok, so far we have:
^!w::Send, Hello World!
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 do not enter return at the end, you will only be able to use the script once, before resetting the program to use it again, etc.

So, our hello world script is finished!
^!w::Send, Hello World!return'''

Step 5: Running Your New Script

Save your newly made script to whatever location you wish. Make sure that it has .ahk on the end. .ahk is the suffix that is added to autohotkey scripts. Now, double click on the script to run it, and your off! Every time you press Ctrl-Alt-w, it will type out Hello World! for you!

Step 6: Other Useful Scripts

There are many other useful scripts available to download off the internet.
For fps gamers, there is a rapid fire script, so that when you hold down the mouse button, the gun you are using will rapid fire, even if its not an automatic weapon.

The rapidfire script is:
#SingleInstancegActivateScript = 0; Insert to activate the macro~Insert::KeyWait, InsertGetKeyState, InsertState, Insert, TIf InsertState = D{    gActivateScript = 1}else{    gActivateScript = 0}return; CTRL + SHIFT + LBUTTON to activate the macro~+^LButton::If gActivateScript = 0{    gActivateScript = 1}else{    gActivateScript = 0}return ;Also applies to burst weapons. ie click and hold will perform like a full auto firing mode~LButton::Goto, DoFiringLoopReturn;When crouching and firing at the same time. Using Ctrl as crouch button~^LButton::Goto, DoFiringLoopReturnDoFiringLoop:if gActivateScript = 1{    Loop    {       ;Make sure Cod4 window is the active window. Don't want weird mouse behaviour appearing at other window        IfWinActive, Call of Duty 4{            MouseClick, left,,, 1, 0, D           ;delay between simu. mouse btn down and up            Sleep, 50            MouseClick, left,,, 1, 0, U            GetKeyState, LButtonState, LButton, P            If LButtonState = U            {               ;break the loop if physical state of mouse btn is up.                break            }           ;delay between each simu. click events            Sleep, 50        }        else        {            break        }    }   }exitreturn
(By the way, i did not code this script. It is written by Byro on autohotkey.com)
To activate this script, just press the insert button on your keyboard!

There are many script repositories all over the internet.
Some of them are:
The Autohotkey Script Showcase
Autohotkey Scripts and Macros @ Autohotkey.free.fr
One Hour Software Script repository

Thank you for taking the time to read my instructable. I hope you had fun and continue to find out about more about Autohotkey coding!

&nbsp;Script could hav been more legible<br /> <br />
can't remember where I got this, but this works too: $x:: Loop { if not GetKeyState("x", "P") break sleep 10 Click } return if you want rapid fire, hold X. very useful. btw, nice instructable. We need more AHK instructables.
i LOVE AHK! i "work" at a free computer support forum ( <Shameless plug> www.geekstogo.com </Shameless plug>) and i use it a lot to post "canned speeches" or automated responses....it's great

About This Instructable




More by idiotjohn:How to use autohotkey and write basic scripts for it. Get into any site that may be blocked - Just have access to My Computer Pulling apart a desktop hard drive to get rare earth magnets. 
Add instructable to: