Table of Contents

  1. The basics
  2. Hotkeys & Hotstrings
  3. Sending key strokes
  4. Running programs & website
  5. Commands vs. Functions()
  6. Variables
  7. Other helpful goodies

1 - The Basics.

Before we begin our journey, let me give some advice. Throughout this tutorial you will see a lot of text and a lot of code. For optimal learning power, it is advised that you read the text and try the code. Then study the code.
You can copy and paste most examples on this page.
If you get confused, try reading the section again.

a. Downloading and installing AutoHotkey

Before learning to use AutoHotkey (AHK), you will need to download it. After downloading it, you may possibly need install it. But that depends on the version you want. For this guide we will use the Installer since it is easiest to set up.

Text instructions:

  1. Go to the AutoHotkey Homepage. http://www.autohotkey.com/
  2. Click Download. http://www.autohotkey.com/download/
  3. During installation of AutoHotkey, you will be asked to choose from UNICODE or ANSI. In short, you would probably want to choose UNICODE. It has support for non-English letters and numbers (characters). Keep going until you see an Install button.
  4. Once done, great! Continue on to section b.

Video instructions:
Frankie's "Install and Hello World"
http://www.autohotkey.com/forum/viewtopic.php?t=77674

b. How to create a script

Once you have AutoHotkey installed, you will probably want it to do stuff. AutoHotkey is not magic, we all wish it was, but it is not. So we will need to tell it what to do. This process is called "Scripting".

Text instructions:

Video instructions:
Frankie's "Install and Hello World"
http://www.autohotkey.com/forum/viewtopic.php?t=77674

c. You cannot merge commands

When you are making your code, you might have the urge to put several commands on the same line or inside of each other, don't. in section 5 we'll talk about why it doesn't work as you might expect and what you can do instead.

d. Other basic info

How to find the Help File on your computer:
There are a few ways to do this, I'll assume you have it installed to the default locations.

Method 1:
  1. Find the Start menu or Start Orb on your screen, usually in the lower left.
  2. Click Programs or All Programs.
  3. Find AutoHotkey in the list.
  4. You should then see AutoHotkey Help File. Click it.
  5. Done!
Method 2:
  1. Go to your desktop.
  2. Find My Computer or Computer. Open it.
  3. Go into your harddrive that contains AutoHotkey. Probably C:\ drive.
  4. Search within all Program Files folders for AutoHotkey.
  5. Look for AutoHotkey.chm or a file that says AutoHotkey and has a yellow question mark on it.
  6. Done!

Online Links:
Documentation
Command List
Functions
Variables

2 - Hotkeys & Hotstrings

What is a Hotkey? A hotkey is a key that is hot to the touch. ... Just kidding. It is a key or key combination that the person at the keyboard presses to trigger some actions.
What is a Hotstring? Hotstrings are mainly used to expand abbreviations as you type them (auto-replace), they can also be used to launch any scripted action.

Here is a hotkey:

^j::
    Send, My First Script
Return

Here is a hotstring:

::ftw::Free the whales

The difference between the two examples is that the hotkey will be triggered when you press CTRL & J while the hotstring will convert your typed "ftw" into "Free the whales".

"So, how exactly does a person such as myself create a hotkey?" Good question. A hotkey is created by using a single pair of ::'s. The key or key combo needs to go on the left of the ::. And the content needs to go below, followed by a return.

Note: Their are exceptions, but those tend to cause confusion a lot of the time. So it won't be covered in the tutorial, at least, not right now.

esc::
   MsgBox Escape!!!!
return

A hotstring has a pair of ::'s on each side of the text you want to trigger the text replacement. While the text to replace your typed text goes on the right of the second pair of ::'s.

Hotstring, as mentioned above, can also launch scripted actions. Thats fancy talk for "do pretty much anything". Same with hotkeys.

::btw::
   MsgBox You typed "btw".
return

A nice thing to know is that you can have many lines of code for each hotkey, hotstring, label, and a lot of other things we haven't talked about yet.

^j::
   MsgBox Wow!
   MsgBox this is
   Run, Notepad.exe
   winactivate, Untitled - Notepad
   WinWaitActive, Untitled - Notepad
   send, 7 lines{!}{enter}
   sendinput, inside the ctrl{+}j hotkey
return

a. Keys and their mysterious symbols

You might be wondering "How the crud am I supposed to know that ^ means CTRL?!". Well, good question. To help you learn what ^ and other symbols mean, gaze upon this chart:
Symbol Description
# Win (Windows logo key). In v1.0.48.01+, for Windows Vista and later, hotkeys that include the Windows key (e.g. #a) will wait for the Windows key to be released before sending any text containing an "L" keystroke. This prevents the Send within such a hotkey from locking the PC. This behavior applies to all sending modes except SendPlay (which doesn't need it) and blind mode.
! Alt
^ Control
+ Shift
& An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey. See below for details. Such hotkeys are ignored (not activated) on Windows 95/98/Me.

(See the Key List for a complete list of keyboard keys and mouse/joystick buttons)
(For the full list of symbols, see the Hotkey page)

Additionally, here is a list of all/most hotkey names that can be used on the left side of a hotkeys :: symbol:
http://www.autohotkey.com/docs/KeyList.htm

You can define a custom combination of two (and only two) keys (except joystick buttons) by using & between them. In the below example, you would hold down Numpad0 then press the second key to trigger the hotkey:

Numpad0 & Numpad1::MsgBox You pressed Numpad1 while holding down Numpad0. |
Numpad0 & Numpad2::Run Notepad                                            |

But you are now wondering if hotstrings have any cool modifiers since hotkeys do. Yes, they do!
Hotstrings modifiers go between the first set of ::'s. Such as:

:*:ftw::Free the whales

For additional hotkey and hotstring modifiers, information and examples, visit:
Hotkeys
Hotstrings

b. Window specific hotkeys/hotstrings

Sometime you might want a hotkey or hotstring to only work (or be disabled) in a certain window. To do this, you will need to use either of these fancy commands with a # in-front of them.

#IfWinActive
#IfWinExist

These special commands (technically called "directives") create context-sensitive hotkeys and hotstrings. Simply specify a windows title. But in some cased you might want to specify an HWND, group, or class. Those are a bit advanced and are covered more in-depth here: #IfWinActive.

#IfWinActive Untitled - Notepad
#space::MsgBox You pressed Win+Spacebar in Notepad.

The #IfWin commands are positional: they affect all hotkeys and hotstrings physically beneath them in the script.

; Notepad
#IfWinActive ahk_class Notepad
#space::
   MsgBox, You pressed Win+Spacebar in Notepad.
return
::msg::You typed msg in Notepad
#IfWinActive

; MSPaint
#IfWinActive untitled - Paint
#space::
   MsgBox, You pressed Win+Spacebar in MSPaint!
return
::msg::You typed msg in MSPaint!
#IfWinActive

To turn off context sensitivity, specify any #IfWin command but leave all of its parameters blank. For example:

; Notepad
#IfWinActive untitled - Notepad
!q::
   MsgBox, You pressed Alt and Q in Notepad.
#IfWinActive

 ; Any window that isn't Untitled - Notepad
!q::
   MsgBox, You pressed Alt and Q in any window.
Return

When #IfWin commands are turned off (or never used in a script), all hotkeys and hotstrings are enabled for all windows.

For more in-depth information and similar commands, check out:
#IfWinActive

c. Multiple hotkeys/hotstrings per file

This, for some reason crosses some peoples minds. So I'll set it clear: AutoHotkey has the ability to have as many hotkeys and hotstrings in 1 file as you want. Whether it's 1, or 3253 (or more).

#i::
   run, http://www.google.com/
return

^p::
   run, notepad.exe
return

~j::
   send, ack
return

::acheiv::achiev
::achievment::achievement
::acquaintence::acquaintance
:*:adquir::acquir
::aquisition::acquisition
::agravat::aggravat
:*:allign::align
::ameria::America

The above code is perfectly acceptable. Multiple hotkeys, multple hotstrings. All in one big happy script file.

d. Examples

::btw::By the way                          ; Replaces "btw" with "By the way" as soon as you press an EndChar.
:*:btw::By the way                         ; Replaces "btw" with "By the way" without needing an EndChar
                                     
^n::                                       ; Ctrl & n Hotkey
   run, notepad.exe                        ; Run the program notepad.exe when you press Ctrl & n
Return                                     ; This ends the hotkey. The code below this will not get triggered.
                                           
^b::                                       ; Ctrl & b Hotkey
   send, {ctrl down}c{ctrl up}             ; Copies the selected text. ^c could be used aswell, but this method is more secure.
   SendInput, [b]{ctrl down}v{ctrl up}[/b] ; Wraps the selected text in bbcode (forum) Bold tags.
Return                                     ; This ends the hotkey. The code below this point will not get triggered.

3 - Sending key strokes

So now you decided that you want to send (type) keys to a program. We can do that. Use the Send command. Send literally sends keystrokes, to simulate typing or pressing of keys.

Before we get into things, here are some common issues that people have:
Just like Hotkeys, Send has special keys too. Lots and lots of them.
Here are the 4 most common symbols:


!: Sends the ALT key. For example, Send This is text!a would send the keys "This is text" and then press ALT+a. Note: !A produces a different effect in some programs than !a. This is because !A presses ALT+SHIFT+A and !a presses ALT+a. If in doubt, use lowercase.

+: Sends the SHIFT key. For example, Send +abC would send the text "AbC", and Send !+a would press ALT+SHIFT+a.

^: Sends the CONTROL (Ctrl) key. For example, Send ^!a would press CTRL+ALT+a, and Send ^{Home} would send CONTROL+HOME. Note: ^A produces a different effect in some programs than ^a. This is because ^A presses CONTROL+SHIFT+A and ^a presses CONTROL+a. If in doubt, use lowercase.

#: Sends the WIN key (the key with the Windows logo) therefore Send #e would hold down the Windows key and then press the letter "e".


The next couple of paragraphs are talking about the table on send page.

Note:
This table does not apply to hotkeys. Meaning, you do not wrap CTRL or ENTER (or any other key) inside {}'s when making a hotkey.


An example showing what shouldn't be done to a hotkey:
; When making a hotkey...
; WRONG
{LCtrl}::
  send, AutoHotkey
return

; CORRECT
LCtrl::
  send, AutoHotkey
return

The gigantic table above shows pretty much every special key built-in to AHK. Such as: {enter} and {space}.
A common issue lots of people have is they assume that the curly brackets are put in the documentation pages just for fun. But in fact they are needed. It's how AHK knows that {!} means "exclamation point" and not "press the Alt key". So please remember to check the table on the send page and make sure you have your brackets in the right places.

; Notice the ! is in {}'s? Thats because if it wasn't, AHK would
; press the ALT key.
send, This text has been typed{!}
; Same as above, but with the ENTER key. AHK would type out "enter" if ...
; ... it wasn't wrapped in {}'s.
send, Multiple enter lines have enter been sent. ; WRONG
send, Multiple{enter}lines have{enter}been sent. ; CORRECT
Another common issue is that people think that everything needs to be wrapped in brackets with the send command. That is FALSE. If it's not in the chart, it does not need brackets. You do not need to wrap common letters, numbers or even some symbols (such as . (period)) in {}'s.
Also, with the Send commands you are able to send more then 1 letter, number or symbol at a time. So no need for a bunch of Send commands with 1 letter each.
; Don't wrap words or indivisual letters that are not in the table mentioned above.
send, {a}       ; WRONG
send, {b}       ; WRONG
send, {c}       ; WRONG
send, {a}{b}{c} ; WRONG
send, {abc}     ; WRONG
send, abc       ; CORRECT
To hold down or release a key, enclose the key name in brackets and then use the word UP or DOWN.
; This is how you hold 1 key down and press another key (or keys).
; If 1 method doesn't work in your program, please try the other.
send, ^s                     ; Both of these send CTRL+s
send, {ctrl down}s{ctrl up}  ; Both of these send CTRL+s
Send, {ctrl down}c{ctrl up}
Send, {b down}{b up}
Send, {TAB down}{TAB up}
Send, {Up down}  ; Press down the up-arrow key.
Sleep, 1000      ; Keep it down for one second.
Send, {Up up}    ; Release the up-arrow key.
But now you are wondering "How can I make my really long send commands readable?". Easy. Use what is known as a Continuation Section. Simply specify an opening parenthesis on a new line, then your content, finally a closing parenthesis on its own line. For more information, read about Continuation Sections.
send,
(
Line 1
Line 2
Apples are a fruit.
)

Note: Their are several different forms of send. Each has there own special features. If one form of send does not work for your needs, try another type of send. Simply replace the commands name "send" with "sendPlay" or whatever you want.
Here are most ways to send text:
Send
SendRaw
SendInput
SendPlay
SendEvent
For more information on what each one does, read this.

a. Games

This is important!
A lot of games, especially modern ones, have cheat prevention software. Things like GameGuard, Hackshield, PunkBuster and several others. If a game has a cheat prevention system and your hotkeys, hotstrings and send commands do not work, you are out of luck.
Not only is bypassing these systems in violation of the games policies and will get you banned, they are complex to work around. Their are methods that can increase the chance of working in some games, but there is no magical "make it work in my game now!!!" button. so try ALL of these before giving up.

Their are also known issues with DirectX. If you are having issues and you know the game uses DirectX, try the stuff above. You should also try running the game in Windowed Mode, if possible. That fixes some DirectX issues.
More DirextX issues may occur when using pixel or image commands. Colors might turn out black (0x000000) no matter the color you try to get. That is another tricky thing to fix. Try running in Windowed Mode if you can.

There is no single solution to make AutoHotkey work in all programs. If everything you try fails, it may not be possible to use AutoHotkey for your needs.


From the FAQ page:
Some games use DirectInput exclusively. As a side-effect, they might ignore all simulated keystrokes and mouse clicks. To work around this, try one of the following (or a combination):
  • Use SendPlay via: 1) the SendPlay command; 2) using SendMode Play; and/or 3) the hotstring option SP.
  • Increase SetKeyDelay. For example:
  • SetKeyDelay, 0, 50
  • SetKeyDelay, 0, 50, Play
  • Try ControlSend, which might work in cases where the other Send modes fail.

4 - Running programs & websites

To run a program such as Mspaint.exe, Calc.exe, script.ahk or even a folder, you can use the Run command. It can even be used to open URLs such as http://www.autohotkey.com/ . If your computer is setup to run the type of program you want to run, it's very simple:
; Run a program. Note: most programs will require a FULL file path.
Run, %A_ProgramFiles%\Some_Program\Program.exe

; Run a website
Run, http://www.autohotkey.com
Their are some other advanced features aswell, such as Command-Line parameters and CLSID.
If you want to learn more about that stuff, visit the run page.
Here are a few more samples:
; Several programs do not need a full path, such as Windows-standard programs.
Run, Notepad.exe
Run, MsPaint.exe

; Run the "My Documents" folder using the built-in AHK variable
Run, %A_MyDocuments%

; Run some websites
Run, http://www.autohotkey.com
Run, http://www.google.com

For more in-depth information and examples, check out:
http://www.autohotkey.com/docs/commands/Run.htm.

5 - Commands vs. Functions()

AutoHotkey has two main types of things used by the scripter to create code:
Commands and Functions()

Helpful links:
A list of all commands: commands.htm
A list of all built-in functions: Functions.htm#BuiltIn

Commands

You can tell what a command is by looking at its syntax (the way it looks). Commands do not use parenthesis "()" around the parameters like functions do. So a command would look like this:
Command, parameter1, parameter2, parameter3
This page contains a list of all Commands that come with AHK.

When using commands, you cannot squish other commands onto the same line as a previous command (exception: ifEqual).
You cannot put commands inside the parameters of other commands.

Msgbox, Hello Run, Notepad.exe   ; Wrong
Msgbox, Hello, Run, Notepad.exe  ; Wrong

Msgbox, Hello      ; Correct
Run, Notepad.exe
Commands also differ from function in that they use "traditional syntax". Meaning: when you use a variable, you NEED to use %'s around it. %variable%. Any text and numbers do not need to be in "quotation marks". This is some text. Additionally, you cannot do math in the parameters, unlike functions().

You can do math in parameters if you force an expression with a single %, but that will not be covered.

Functions

As stated above, functions are different because they use parenthesis. A typical function looks like:
Function(parameter1, parameter2, parameter3)

Functions have a few main differences:
  1. You can do math in them.
    -- SubStr(37*12, 1, 2)
    -- SubStr(A_Hour-12, 2)
  2. Variables do not need to be wrapped in percent signs.
    -- SubStr(A_Now, 7, 2)
  3. Functions can go inside of functions.
    -- SubStr(A_AHKPath, inStr(A_AHKPath, "AutoHotkey"))
  4. Text needs to be wrapped in quotes.
    -- SubStr("I'm scripting, awesome!", 16)
Functions usually return a value differently than a command does. Commands need an OutputVariable parameter, functions do not. The most common way to assign a variable to the value of a function is like so:
MyVariable:=Function(Parameters)
MyVariable:=SubStr("I'm scripting, awesome!", 16)

This isn't the only way, but it's the most common. You are assigning MyVariable to the value of the function (in this case, SubStr(...)) that is to the right of the :=.
More about Functions

In short:
; These are commands
Msgbox, This is some text.
StringReplace, Output, Input, AutoHotKey, AutoHotkey, ALL
SendIput, This is awesome{!}{!}{!}

; These are Functions
SubStr("I'm scripting, awesome!", 16)
FileExist(VariableContainingPath)
Output:=SubStr("I'm scripting, awesome!", 16)

a. Code blocks

Code blocks are little curly brackets ({ and }) that are there to group a section of code together so that AutoHotkey knows it's one big family and that it needs to stay together. They are most often used with If and Loops. Without them, only the first line in the block is called.

In the following code, both lines are ran only if var equals 5.
if (var=5)
{
   MsgBox, var equals %var%!!
   Exitapp
}

In the following code, the msgbox is only ran if var equals 5. The code will always exit, even if var=5.
if (var=5)
   MsgBox, var equals %var%!!
   Exitapp

This is perfectly fine since the if only had 1 line of code associated with it. It's exactly the same as above, but I outdented the second line so we know it's separate from the if.
if (var=5)
   MsgBox, var equals %var%!!
MsgBox, We are now 'outside' the if. We did not need {}'s since there was only 1 line below it.

6 - Variables

Variables are like little post-it notes that hold some information. They can be used to store text, numbers, data from functions and commands or even mathematical equations. Without them, programming & scripting would be much more tedius.


Variables can be assigned a few ways, We'll cover the most common forms. Please pay attention to the equal sign (=).
  1. variable=text
    This is the simplest form for a variable, traditional assignment. Simply type in your text and done.
  2. variable=%variable2%
    Same as above, but you are assigning a variable to a different variables value.
  3. variable:="text"
    This is an expression assignment, due to the : before the =. Any text needs to be in "quotes".
  4. variable:=variable2
    In expression mode, variables do not need %'s.
  5. variable:=6+8/3*2-sqrt(9)
    Thanks to expressions, you can do math!
Number 1 & 2 can be combined. var=%var2% some text %var3%.
3, 4 & 5 can be combined too. var:="The value of 5+ " Variable " is: " 5+Variable

Any equal sign (=) with a symbol infront of it is called an Assignment Operator, which are always an expression. So := += -= .= etc. always use expressions.

a. When to use percents

One of the most common issues with AutoHotkey involving variables is when to use the percent signs (%). Hopefully this will clear some confusion.

When to use %'s:
  1. When you are using Commands (see above) you use percent signs.
    -- Except when the parameter is OutputVar or InputVar.
  2. When you are assigning a variable to a value using a traditional mode (an equal sign with no symbol infront of it).
When not to use %'s:
  1. In parameters that are input or output variables, For example: StringLen, OutputVar, InputVar
  2. On the left side of an assignment: Var = 123abc
  3. On the left side of traditional (non-expression) if-statements: If Var1 < %Var2%
  4. Everywhere in expressions. For example:
    If (Var1 <> Var2)
    Var1 := Var2 + 100
    

b. Getting user input

Sometimes you want to have the user to choose the value of stuff. Their are several ways of doing this, but the simplest way is Inputbox. Here is a simple example on how to ask the user a couple of questions and doing some stuff with what was entered.
InputBox, OutputVar, Question 1, What is your first name?
if (OutputVar="Bill")
   MsgBox, That's is an awesome name, %OutputVar%.

InputBox, OutputVar2, Question 2, Do you like AutoHotkey?
if (OutputVar2="yes")
   MsgBox, Thank you for answering %OutputVar2%`, %OutputVar%! We will become great friends.
else
   MsgBox, %OutputVar%`, That makes me sad.

c. other examples?

MsgBox, 4, , Would you like to continue?
IfMsgBox, No
   return                ; If No, stop the code from going further.
MsgBox You pressed YES.  ; Otherwise, the user picked yes.
; Some examples showing when to use percents and when not
Variable=text                      ; Assign a variable some text using 'traditional' assignment.
VariableNumber:=6                  ; Assign a variable a number using 'expressional' assignment.
Variable2=%Variable%               ; Assign a variable to another variable using traditional assignment.
Variable3:=Variable                ; Assign a variable to another variable using expressional assignment.
Variable4.=Variable                ; Append a variable to the end of another variable using expressional assignment.
Variable5+=VariableNumber          ; Add the value of a variable to another variable using expressional assignment.
Variable5-=VariableNumber          ; Subtract the value of a variable from another variable using expressional assignment.
Variable6:=SubStr(Variable, 2, 2)  ; Variable inside a function. This is always an expression.
MsgBox, %Variable%                 ; Variable inside a command. 
StringSplit, Variable, Variable, x ; Variable inside a command that uses InputVar and OutputVar.
if (VariableNumber=6)              ; Whenever an IF has parenthesis, it'll be an expression. So no %'s.
If (Variable != VariableNumber)    ; Whenever an IF has parenthesis, it'll be an expression. So no %'s.
if VariableNumber=6                ; Without parenthesis, the if is Traditional. However, only variables on the 'right side' need %'s. 
If Var1 < %Var2%                   ; Without parenthesis, the if is Traditional. However, only variables on the 'right side' need %'s. 

7 - Other helpful goodies

We have reached the end of our journey, my good friend. I hope you have learned something. But before we go, here are some other things that I think you should know. Enjoy!

a. The mysterious []'s

Throughout the documentation, you will see these two symbols ([ and ]) surrounding code in the yellow syntax box at the top of almost all pages. Anything inside of these brackets are OPTIONAL. Meaning the stuff inside can be left out if you don't need them. When writing your code, it is very important to NOT type the []'s in your code.

On the ControlGetText page you will see this (without the colors):
ControlGetText, OutputVar [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]

So you could simply do this if you wanted:
ControlGetText, OutputVar

Or add in some more details:
ControlGetText, OutputVar, Control, WinTitle

What if you wanted to use ExludeTitle but not fill in WinText or WinTitle? Simple!
ControlGetText, OutputVar, Control,,, ExcludeTitle

Please note that you cannot IGNORE parameters, you can however leave them blank.
If you were to Ignore "WinTitle, WinText", it would look like this and cause issues:
ControlGetText, OutputVar, Control, ExcludeTitle
This is valid.
ControlGetText, OutputVar, Control,,, ExcludeTitle

b. Finding your AHK version

Run this code to see your AHK version:
MsgBox, %A_AHKVersion%
Or look for "AutoHotkey Help File" or "AutoHotkey.chm" in the start menu or your installation directory.

c. Trial and Error

Trial and Error is a very common and effective way of learning. Instead of asking for help on every little thing, sometimes spending some time alone (sometimes hours or days) and trying to get something to work will help you learn faster.

If you try something and it gives you an error, study that error. Then try and fix your code. Then try running it again. If you still get an error, modify your code some more. Keep trying and failing until your code fails no more. You will learn a lot this way by reading the documentation, reading errors and learning what works and what doesn't. Try, fail, try, fail, try, try, try, fail, fail, succeed!

This is how a lot of "pros" have learned. But don't be affraid to ask for help, we don't bite (hard). Learning takes time, the "pros" you encounter did not learn to be masters in just a few hours or days.

"If at first you don't succeed, try, try, try again." - Hickson, William E.

d. Indentation

This stuff (indentation) is very important! Your code will run perfectly fine without it, but it will be a major headache for you and other to read your code. Small code (25 lines or less) will probably be fine to read without indentation, but it'll soon get sloppy. It's best you learn to indent ASAP.
Indentation has no set style, but it's best to keep everything consistent.
"What is indentation?" you ask? It's simply spacing to break up your code so you can see what belongs to what. People usually use 3 or 4 spaces or 1 tab per "level".

No indents:
if (car="old")
{
msgbox, the car is really old
if (wheels="flat")
{
msgbox, this car is not safe to drive.
return
}
else
{
msgbox, Be careful! This old car will be dangerous to drive.
}
}
else
{
msgbox, My`, what a shiny new vehicle you have there.
}
Indented:
if (car="old")
{
   msgbox, the car is really old
   if (wheels="flat")
   {
      msgbox, this car is not safe to drive.
      return
   }
   else
   {
      msgbox, Be careful! This old car will be dangerous to drive.
   }
}
else
{
   msgbox, My`, what a shiny new vehicle you have there.
}
Wiki has various styles and examples. Choose what you like or learn to indent how you think it's easiest to read.
http://en.wikipedia.org/wiki/Indent_style

e. Asking for Help

Before you ask, try doing some research yourself or try to code it yourself. If that did not yield results that satisfy you, read below. If you don't get an answer right away, wait atleast 1 day (24 hours) before asking for more help. We love to help, but we also do this for free on our own time. We might be at work, sleeping, gaming, with family or just too busy to help.
And while you wait for help, you can try learning and doing it yourself. It's a good feeling, making something yourself without help.

f. Other links

Frequently Asked Questions (FAQ)