AutoIt


AutoIt is a freeware programming language for Microsoft Windows. In its earliest release, it was primarily intended to create automation scripts for Microsoft Windows programs but has since grown to include enhancements in both programming language design and overall functionality.
The scripting language in AutoIt 1 and 2 was statement-driven and designed primarily for simulating user interaction. From version 3 onward, the AutoIt syntax is similar to that found in the BASIC family of languages. In this form, AutoIt is a general-purpose, third-generation programming language with a classical data model and a variant data type that can store several types of data, including arrays.
An AutoIt automation script can be converted into a compressed, stand-alone executable which can be run on computers even if they do not have the AutoIt interpreter installed. A wide range of function libraries are also included as standard or are available from the website to add specialized functionality. AutoIt is also distributed with an IDE based on the free SciTE editor. The compiler and help text are fully integrated and provide a de facto standard environment for developers using AutoIt.

Features

AutoIt is typically used to produce utility software for Microsoft Windows and to automate routine tasks, such as systems management, monitoring, maintenance, or software installation. It is also used to simulate user interaction, whereby an application is "driven" to do things by an AutoIt script.
AutoIt can also be used in low-cost laboratory automation. Applications include instrument synchronisation, alarm monitoring and results gathering. Devices such as CNC routers and 3D-printers can also be controlled.

Examples

Hello world


; Make available a library of constant values.
  1. include
; Displays "Hello, world!" in a messagebox.
MsgBox

Automating the Windows Calculator


; Make available a library of constant values.
  1. include
; Display a message box with a timeout of 6 seconds.
MsgBox
; Run the Windows Calculator.
Run
; Wait for the calculator to become active with a timeout of 10 seconds.
WinWaitActive
; If the calculator did not appear after 10 seconds then exit the script.
If WinExists = 0 Then Exit
; Automatically type the current year into the calculator.
Send
; Let's slow the script down a bit so we can see what's going on.
Sleep
; Automatically type in 'divide by 4', and then sleep 600 ms.
Send
Sleep
; Hit the return key to display the result, and sleep 600 ms.
Send
Sleep
; Copy the result to the clipboard using the Windows shortcut Ctrl+C.
Send
; Declare, and assign the contents of the clipboard to, a variable.
Local $fResult = ClipGet
; Check to see if the variable contains a decimal point or not.
If StringInStr Then
; Display a message box with a timeout of 5 seconds.
MsgBox
Else
; This message will only display if the current year is a leap year.
MsgBox
EndIf
; Close the Windows calculator - always tidy up afterwards.
WinClose

Find average


; Find Average by JohnOne, modified by czardas
  1. include
_Example ; Run the example.
Func _Example
; Display an input box and ask the user to enter some numbers separated by commas.
Local $sInput = InputBox
; If an error occurred then exit the script.
If @error Then Exit
; Populate an array with the user's input.
Local $aSplit = StringSplit
; Pass the array to the function _Find_Average and then check for errors.
Local $fAverage = _Find_Average
If @error Then Exit
; Display the result in a message box.
MsgBox
EndFunc ;>_Example
Func _Find_Average
; If the input is not of the correct type, then return an error along with the details.
If Not IsArray Then Return SetError
; More detailed checks are possible, but for brevity just one is performed here.
; Declare a variable to store the sum of the numbers.
Local $iArraySum = 0
; Loop through the array.
For $i = 1 To $aArray
; Increment the sum by the number in each array element.
$iArraySum += Number
Next
; Return the average rounded to 2 decimal places.
Return Round
EndFunc ;>_Find_Average

History

The developers of AutoIt originally released the source code under the GNU General Public License, but the practice was discontinued beginning with version 3.2.0 in August 2006. Following the terms of the GPL, some of the code from version 3.1 was used to create a fork by the AutoHotkey project, where the community is continuing to develop and release the code under the GPL.