Language Reference - User Functions

A function is a section of code that can be called from the script to perform a certain "function". There are two sorts of functions in AutoIt, built-in functions and user functions.

Note that all function names are case insensitive: msgbox() is read as MsgBox() and MyFunc() is the same as MyfunC()

Built-in Functions

The full list of built-in functions is here and the notes on using them are here.

User Functions

User functions are declared using the Func...EndFunc statements.

Functions can accept parameters and return values as required.

Function names must start with either a letter or an underscore, and the remainder of the name can contain any combination of letters and numbers and underscores. Some valid function names are:




Here is an example of using a function to double a number 10 times:

#include <Constants.au3>

Local $iNumber = 10
Local $iDoubled = 0

For $i = 1 To 10
    $iDoubled = MyDouble($iNumber)
    MsgBox($MB_OK, "", $iNumber & " doubled is " & $iDoubled)
    $iNumber = $iDoubled

Func MyDouble($iValue)
    $iValue = $iValue * 2
    Return $iValue
EndFunc   ;==>MyDouble