AutoIt

from Wikipedia, the free encyclopedia
AutoIt

AutoIt-logo.svg
Basic data

developer Jonathan Bennett & team
Publishing year January 1999
Current  version 3.3.14.5
(March 16, 2018)
operating system Windows
programming language C ++
category Scripting language
License Freeware
German speaking Yes
www.autoitscript.com

AutoIt is software for executing scripts with which mainly processes under Microsoft Windows can be automated , but also complete Windows programs can be written. AutoIt is freeware and runs on NT , 2000 , XP , Vista , 7 , 8 and 10 . Up to version 2 it was open source and from version 3 parts of the source code were published under a restrictive license. Only a few documentation build files are currently available. The program provides the user with a BASIC- like scripting language . It also contains an interpreter and a compiler with which executable files ( exe files ) can be created; this allows AutoIt scripts to be run on computers that do not have AutoIt installed.

function

AutoIt scripts simulate keystrokes and mouse clicks, among other things . The sequence can be made dependent on the fact that a certain process is running or has ended, or that a certain window is activated, opened or closed. Windows can also be minimized, hidden, activated or closed; Files and directories can be executed, copied, moved, renamed or deleted. The contents of the clipboard and the registration database can also be edited. With version 3 (as of August 2008) the following operations are possible:

  • Creation of GUIs including message windows and input boxes
  • Automatic sending of user input and keystrokes to applications as well as individual control within applications
  • Use of COM ( Component Object Modeling ) objects
  • Call of functions of a Win32 DLL
  • Call of functions from the WinAPI
  • Execution of console applications and access to standard data streams
  • Including files in the compiled file, which can be extracted at a defined point in time
  • Play sound files, pause, continue, stop, search, current playback position and length of the sound
  • Perform complex mathematical calculations
  • Communication via TCP and UDP protocol
  • Unicode support from version 3.2.4.0
  • Support of ActiveX processes ( WSH / VBScript ) with the "AutoItX" extension
  • Database access (for example to SQLite [in the installation package])
  • Automation of Internet Explorer
  • Automation of Microsoft Word and Microsoft Excel

With version 3.2 AutoIt has been greatly expanded and numerous program errors have been eliminated. In addition, scripts can be saved as a3x files and the GUI functions have been improved.

AutoIt script example

$sName = InputBox("Fenstertitel", "Geben Sie hier Ihren Namen ein!")

An input box is displayed that asks you to enter your name. The name is $sNamesaved in the variable .

MsgBox(64, "Fenstertitel", "Hallo " & $sName & "!")

With this command a message box is displayed, which $sNameoutputs the content of the variable . The value 64 identifies the window as an “info box” (warnings, questions or error messages are also possible).

Example of an advanced AutoIt script

#cs	Startet einen Kommentar-Block

Standard-Präfixe für Variablen:

	- $h 	- Handle von z. B. einem Fenster oder einer Datei
	- $id 	- ID's von Controls, wie z. B. Buttons und Eingabefelder
	- $s	- Strings (Zeichenketten)
	- $i	- Integers (Ganzzahlen)

	Variablennamen werden normalerweise in Englisch verfasst! (Kein Standard)

#ce	; Beendet einen Kommentar-Block


#include <FTPEx.au3> ; Einbinden von mehreren vordefinierten Scripten.
#include <GUIConstantsEx.au3>

;############# Änderbare Daten ################
$sIP = "IP von FTP-Server"
$sUser = "Benutzername vom FTP-Benutzer"
$sPassword = "Passwort vom FTP-Benutzer"
$sFTP_Path = "Pfad auf dem Server"
;##############################################

$hGUI = GUICreate("TestGUI", 445, 339) ; In der Mitte des Bildschirms wird mit der X-Koordinate 445, und der Y-Koordinate 339 ein Fenster gezeichnet.
GUISetBkColor(0xBFCDDB) ; Die Hintergrundfarbe wird vom Standard geändert.
$idSend = GUICtrlCreateButton("Versenden", 0, 288, 203, 49) ; Der "Versenden"-Knopf wird erstellt.
$idEdit = GUICtrlCreateEdit("", 0, 0, 441, 289) ; Ein Eingabefeld wird erstellt.
GUICtrlSetData($idEdit, "Beispiel-Text" & @CRLF & "Nächste Zeile") ; Ein Text wird in das Eingabefeld geschrieben. @CRLF markiert einen Zeilenumbruch.
GUICtrlSetBkColor($idEdit, 0xC0C0C0) ; Die Hintergrundfarbe des Eingabefeldes wird geändert.
GUISetState(@SW_SHOW) ; Das Fenster wird angezeigt.

While 1 ; Eine While-Schleife wird geöffnet, die immer wieder bestimmte Sachen abfragt. Endlosschleife, in diesem Fall die "Messageloop" des Fensters.
        $iMsg = GUIGetMsg() ; Die Variable die abgefragt werden soll, wird immer wieder neu erstellt. (Einmal pro durchlauf der Schleife.)
        Switch $iMsg ; Die Variable wird als Ereignisauslöser definiert.
            Case $GUI_EVENT_CLOSE ; Falls der "Schließenknopf"(X oben rechts in der Ecke) gedrückt wird,
                Exit ; beendet sich das Script.
            Case $idSend ; Falls der "Versenden"-Button gedrückt wird,
                _Put_on_FTP() ; wird die "_Put_on_FTP" Funktion ausgeführt.
        EndSwitch ; Die Abfrage der Variable $nMsg wird beendet.
WEnd ; Markiert das Ende einer "While"-Schleife(n) definition. Falls die Schleife endet, arbeitet das Skript von hier weiter.

Func _Put_on_FTP() ; Benutzerdefinierte Funktionen haben normalerweise das Präfix "_" und der Name sollte auch in Englisch gehalten sein.
        Local $sFilePath = "ftp.txt" ; Eine lokale Variable wird deklariert und ein Wert zugewiesen (diese ist nur in dieser Funktion verfügbar).

        $hFile = FileOpen($sFilePath, 10) ; Eine Datei wird zum Schreiben geöffnet, und falls sie nicht existiert, wird diese erstellt.
        $sText = GUICtrlRead($idEdit) ; Der Text aus dem Eingabefeld wird eingelesen.
        FileWrite($hFile, $sText) ; In die zuvor geöffnete Datei wird der Text aus der Variablen $sText geschrieben.
        FileClose($hFile) ; Die Datei wird geschlossen und die Ressourcen wird freigegeben.
        $hFTP = _FTP_Open("TestFTP") ; Die FTP-Sitzung wird gestartet.
        $hFTP_Connection = _FTP_Connect($hFTP, $sIP, $sUser, $sPassword) ; Eine FTP-Verbindung zum angegebenen Server wird aufgebaut.
        If @error <> 0 Then ; Falls @error ungleich 0 ist (ein Fehler ist aufgetreten),
                MsgBox(0, "Error", "Der FTP-Server scheint nicht erreichbar zu sein.") ; Eine Fehlermeldung wird ausgegeben.
            ElseIf @error = 0 Then ; Falls @error gleich 0 ist (kein Fehler ist aufgetreten),
                _FTP_FilePut($hFTP_Connection, $sFilePath, $sFTP_Path) ; wird Die Testdatei auf den Server geschrieben.
                If @error Then ; Falls es einen Fehler gibt, ...
                        MsgBox(0, "Error", "Es trat ein Fehler beim Übertragen auf.") ; ... wird eine Fehlermeldung angezeigt, ansonsten ...
                    Else ; Wenn kein Fehler aufgetreten ist,
                        MsgBox(0, "Erfolg", "Die Datei wurde erfolgreich übertragen.") ; ... war die Operation erfolgreich.
                EndIf ; Die If-Abfrage wird geschlossen.
        EndIf ; Die erste If-Abfrage wird geschlossen.
        _FTP_Close($hFTP) ; Die FTP-Verbindung wird geschlossen und die FTP-Sitzung wird beendet.
        FileDelete($sFilePath) ; Die temporäre Datei wird gelöscht.

        Return ; Funktion beenden und mit der eigentlichen Skript-Ausführung fortfahren.
EndFunc ; Markiert das Ende einer Funktion.

Extensions and additional programs

  • There is an adapted version ("SciTE4AutoIt3") of SciTE as an integrated development interface (IDE) for AutoIt. The freeware program editor supports syntax highlighting as well as auto-complete and some macros for creating frequently used syntax elements. SciTE4AutoIt3 can be downloaded free of charge from the AutoIt homepage.
  • Numerous additional functions are available via so-called User Defined Functions (UDFs) or includes; Thanks to extensions created by the community, the current range of functions includes much more than the list above.
  • The KODA-Form-Designer enables the simplified creation of graphical user interfaces (GUI, Graphical User Interfaces) for AutoIt scripts.
  • Tidy "cleans up" an AutoIt script by correcting indentation, capitalization, comments, and more.
  • With the CodeWizard, message boxes (message windows), input boxes (input windows) and much more can be generated. There is an online version of the messagebox generator.
  • AutoIt Window Info is an extension that is used to read information from a window or the mouse pointer (e.g. the window or mouse position, pixel colors, control coordinates).
  • The points mentioned above are already integrated in SciTE4AutoIt3.

See also

  • AutoHotkey - Alternative software under an open source license that is derived from version 2 of AutoIt

Web links

Individual evidence

  1. ^ Jon: AutoIt Source Code. In: AutoItScript Forum. February 8, 2005, accessed September 4, 2018 .
  2. Change log