AutoIt

AutoIt
Developer(s) Jonathan Bennett & AutoIt Team
Initial release January 1999 (1999-01)
Stable release
3.3.14.2 / September 18, 2015 (2015-09-18)[1]
Operating system Microsoft Windows
Type GUI Scripting language Automation
License Freeware closed source
Website www.autoitscript.com/autoit3/

AutoIt /ɔːt ɪt/[2] is a freeware automation language for Microsoft Windows. In its earliest release, the software was primarily intended to create automation scripts (sometimes called macros) for Microsoft Windows programs[3] but has since grown to include enhancements in both programming language design and overall functionality.

While the scripting language in AutoIt 1 and 2 was statement-driven, designed primarily for simulating user interaction, from version 3 onwards 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. While version 1 and 2 were compatible with Windows 95, 98, ME, NT4, 2000, XP, 2003, Vista, Windows 7, support for operating systems older than Windows 2000 was discontinued with the release of v3.3.0 in December 2008).[4] Currently AutoIt is compatibile also with Windows 2008, Windows 8, Windows 2012, Windows 10, and minimal requirement is XP+SP3.

An AutoIt automation script can be converted into a compressed, stand-alone executable which can be run on computers that do not have the AutoIt interpreter installed. A wide range of function libraries (known as UDFs, or "User Defined Functions")[5] 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.

AU3 File Format Icon

Features

The AutoIt SciTE editor.

Usage

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" (via automated form entry, keypresses, mouse clicks, and so on) to do things by an AutoIt script.

Examples

Hello world

; Make available a library of constant values.
#include <MsgBoxConstants.au3>

; Displays "Hello, world!" in a messagebox.
MsgBox($MB_SYSTEMMODAL, "Title", "Hello, world!")

Automating the Windows Calculator

; Make available a library of constant values.
#include <MsgBoxConstants.au3>

; Display a message box with a timeout of 6 seconds.
MsgBox($MB_OK, "Attention", "Avoid touching the keyboard or mouse during automation.", 6)

; Run the Windows Calculator.
Run("calc.exe")

; Wait for the calculator to become active with a timeout of 10 seconds.
WinWaitActive("[CLASS:CalcFrame]", "", 10)

; If the calculator did not appear after 10 seconds then exit the script.
If WinExists("[CLASS:CalcFrame]") = 0 Then Exit

; Automatically type the current year into the calculator.
Send(@YEAR)

; Let's slow the script down a bit so we can see what's going on.
Sleep(600)

; Automatically type in 'divide by 4', and then sleep 600 ms.
Send("/4")
Sleep(600)

; Hit the return key to display the result, and sleep 600 ms.
Send("{ENTER}")
Sleep(600)

; Copy the result to the clipboard using the Windows shortcut Ctrl+C.
Send("^c")

; 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($fResult, ".") Then
    ; Display a message box with a timeout of 5 seconds.
    MsgBox($MB_OK, "Leap Year", @YEAR & " is not a leap year.", 5)
Else
    ; This message will only display if the current year is a leap year.
    MsgBox($MB_OK, "Leap Year", @YEAR & " is a leap year.", 5)
EndIf

; Close the Windows calculator - always tidy up afterwards.
WinClose("[CLASS:CalcFrame]")

Find average

; Find Average by JohnOne, modified by czardas
#include <MsgBoxConstants.au3>

_Example() ; Run the example.

Func _Example()
    ; Display an input box and ask the user to enter some numbers separated by commas.
    Local $sInput = InputBox("Find Average", "Enter some numbers separated by commas: 1,2,42,100,3")

	; If an error occurred then exit the script.
	If @error Then Exit

    ; Populate an array with the user's input.
    Local $aSplit = StringSplit($sInput, ",")

    ; Pass the array to the function _Find_Average() and then check for errors.
    Local $fAverage = _Find_Average($aSplit)
    If @error Then Exit

    ; Display the result in a message box.
    MsgBox($MB_OK, "Find Average", "Result: " & $fAverage)
EndFunc   ;==>_Example

Func _Find_Average($aArray)
    ; If the input is not of the correct type (an array), then return an error along with the details.
    If Not IsArray($aArray) Then Return SetError(1, 0, VarGetType($aArray))
	; 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[0]
        ; Increment the sum by the number in each array element.
        $iArraySum += Number($aArray[$i])
    Next

    ; Return the average rounded to 2 decimal places.
    Return Round($iArraySum / $aArray[0], 2)
EndFunc   ;==>_Find_Average

History

The developers of AutoIt originally released the source code under the GNU General Public License (GPL), 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,[8] where the community is continuing to develop and release the code under the GPL.

See also

References

External links

This article is issued from Wikipedia - version of the 11/17/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.