A quick reference for the AutoIt programming language.
|
$aFruitsList
|
Array ($a)
|
|
$bIsVisible
|
Bool ($b)
|
|
$dBinData
|
Binary ($d)
|
|
$fPrice
|
Float ($f)
|
|
$hGui
|
Handle ($h)
|
|
$iNumber
|
Integer ($i)
|
|
$idButtonOk
|
GUI control id ($i)
|
|
$mPairs
|
Map ($m)
|
|
$oExcel
|
Object ($o)
|
|
$pRect
|
Pointer ($p)
|
|
$sText
|
String ($s)
|
|
$tSTRUCT
|
Struct ($t)
|
|
$vData
|
Variant ($v)
|
|
Global
|
Scope over the entire program
|
|
Local
|
Scope related to the block of code
|
|
Dim
|
Hybrid-like scope, local if not exists already globally
|
|
=
|
Assignment
|
$sText = 'Hi'
|
|
&
|
Concatenates/joins two strings
|
$sText & ' Max'
|
|
&=
|
Concatenation assignment
|
$sText &= ' Max' equivalent to $sText = $sText & ' Max'
|
|
+=
|
Addition assignment
|
$iNum += 1 equivalent to $iNum = $iNum + 1
|
|
-=
|
Subtraction assignment
|
$iNum -= 1 equivalent to $iNum = $iNum -1
|
|
*=
|
Multiplicative assignment
|
$iNum *= 2 equivalent to $iNum = $iNum * 2
|
|
/=
|
Divisive assignment
|
$iNum /= 2 equivalent to $iNum = $iNum / 2
|
|
+
|
Addition
|
10 + 20
|
|
-
|
Subtraction
|
20 - 10
|
|
*
|
Multiplication
|
20 * 10
|
|
/
|
Division
|
20 / 10
|
|
^
|
Power
|
2 ^ 4
|
|
Mod
|
Modulus
|
Mod(val1, val2)
|
|
=
|
Equal (CI)
|
If $sText = 'Hi' Then ..
|
|
==
|
Strict equal (CS)
|
If $sText == 'Bye' Then ..
|
|
<>
|
Not equal (CI)
|
If $sText <> 'hello' Then ..
|
|
>
|
Greater than (CL)
|
|
|
>=
|
Greater than or equal (CL)
|
|
|
<
|
Less than (CL)
|
|
|
<=
|
Less than or equal (CL)
|
|
|
? :
|
Ternary
|
See section "Branching"
|
|
And
|
Logical And
|
If $iNum1 = 5 And $iNum2 > 6 Then ..
|
|
Or
|
Logical Or
|
If $iNum1 = 5 Or $iNum2 > 6 Then ..
|
|
Not
|
Logical Not
|
If Not $iNum = 5 Then ..
|
|
;
|
Single line comment
|
|
#cs
#ce |
This is a multi line comment |
|
"First string"
|
Strings are enclosed in double-quotes
|
|
'Second string'
|
Strings can also be enclosed in single-quotes
|
|
"His name was ""Max"""
|
Double-quotes as escape character
|
|
'His name was "Max"'
|
Or single-quotes instead
|
|
'I''m a string'
|
Single-quotes as escape character
|
|
"I'm a string"
|
Or double-quotes instead
|
|
Without parameters
|
Func _PrintHello()
ConsoleWrite('Hello' & @CRLF) EndFunc |
|
With parameters
|
Func _PrintText($sText)
ConsoleWrite($sText & @CRLF) EndFunc |
|
With optional parameters
|
Func _SendWithDelay($sKeys, $iDelay = 150)
Send($sKeys) Sleep($iDelay) EndFunc |
|
With Default keyword parameter
|
Func _SendWithDelay($sKeys, $iDelay = Default)
$iDelay = ($iDelay == Default) ? 150 : $iDelay Send($sKeys) Sleep($iDelay) EndFunc |
|
For..Next
|
For $i = 1 To 10 Step 1
ConsoleWrite($i & @CRLF) Next |
|
For..In..Next
|
For $sFruit In $aFruitsList
ConsoleWrite($sFruit & @CRLF) Next |
|
While..WEnd
|
While $iNum < 25
Sleep(200) $iNum += 1 WEnd |
|
Do..Until
|
Do
Sleep(200) $iNum += 1 Until $iNum = 25 |
|
If..ElseIf..Else
|
If $iNum = 1 Then
; do something ElseIf $iNum = 2 Then ; do something Else ; do something EndIf |
|
Select
|
Select
Case $iNum = 42 ; do something Case $sText = 'Test' ; do something Case Else ; do something EndSelect |
|
Switch
|
Switch @HOUR
Case 6 To 11 $sMessage = 'Good Morning' Case 12 To 17 $sMessage = 'Good Afternoon' Case Else $sMessage = "Later than 17 o'clock" EndSwitch |
|
Ternary
|
$sVariable = (condition) ? 'thenExpression' : 'elseExpression'
$bIsAnswerToLife = ($iNum = 42) ? True : False |
|
$CmdLine[0]
|
Total number of given command line call parameters
|
|
$CmdLine[1]
|
First parameter (value) of given command line call
|
|
@Compiled
|
Indicates whether the script is compiled or not
|
|
@CRLF
|
Carriage Return Line Feed
|
|
@error
|
Status of the error flag
|
|
@extended
|
Extended function return
|
|
@HOUR
|
Hours value of clock
|
|
@MIN
|
Minutes value of clock
|
|
@SEC
|
Seconds value of clock
|
|
@ScriptDir
|
Directory containing the running script
|
|
#include
|
Includes a file in the current script
#include <Array.au3> or #include "path\filename.au3" |
|
#include-once
|
Current file may only be included once
|
|
#NoTrayIcon
|
AutoIt tray icon will not be shown
|
|
#OnAutoItStartRegister
|
Registers a function to be called when AutoIt starts
|
|
#pragma
|
Changes how the script is compiled
|
|
#RequireAdmin
|
Current script requires full administrator rights to run
|
|
-d
|
As Opt("MustDeclareVars", 1)
|
|
-w 1
|
Already included file (on)
|
|
-w 2
|
Missing #comments-end (on)
|
|
-w 3
|
Already declared var (off)
|
|
-w 4
|
Local var used in global scope (off)
|
|
-w 5
|
Local var declared but not used (off)
|
|
-w 6
|
Warn when using Dim (off)
|
|
-w 7
|
Warn when passing Const or expression on ByRef param(s) (on)
|
|
/sf
|
Strip all unused Func's
|
|
/sv
|
Strip unused Global and Local variable declarations
|
|
/mo
|
Just merges the Include files into the source and strips the Comments
This is similar to aut2exe and helps finding the errorline |
|
/rm
|
Rename Variables and Functions to a shorter name
|
|
/rsln
|
Replace @ScriptLineNumber with the actual line number
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.