|Last modified: 27-03-2015|
AutoIt was first released in 1999, with a lot of the syntax and ideas coming from ScriptIt, a Microsoft project itself based on WinBatch. As of August 2009, AutoIt is freeware (I guess that means closed-source), while AHK is an open-source alternative to AutoIt based on a fork of AutoIt that occurred in 2003 when the source code of AutoIt was still available on request.
The core of AHK was written from scratch, but includes some AutoIt3 code to implement some commands.
The AutoIt community feels that the AHK author didn't give enough credit when forking the code, and since then, no love is lost from the AutoIt community toward AHK.
BASIC-like syntax, can generate compiled GUI programs, built-in COM support, Unicode handling, data types, arrays, much better flow controls (loops, conditionals, switches), better networking support.
In addition to the online docs, wiki, the CHM files, and the forum, information can also be found in Learning To Script with AutoIt V3, AutoIT 1-2-3, and O'Reilly's AutoIt v3: Your Quick Guide by Andy Flesner.
As of version 220.127.116.11, AutoIT consists in the following programs:
Go to \Extras\Au3Record\, and launch Au3Record.exe to record an action that Au3Record will then save as source code that you can use in your scripts.
Note: _WinWaitActivate() is not part of AutoIT; Its code found below must be included in the script.
Caution: Code generated Au3Record isn't always reliable, as some functions won't work. YMMV.
CHECK To have Au3Record generate all the code, you have to start the AU3Record program from inside SciTE, with an AutoIt script open in it, or start the recorder with the /o option to get that checkbox to appear.
Launch the SciTE editor in install\SciTe\SciTE.exe, where you can copy-paste the action you just recorded with Au3Record.exe.
For $i = 5 To 1 Step -1
MsgBox($MB_SYSTEMMODAL, "", "Count down!" & @CRLF & $i)
MsgBox(64, "My title", "My text")
$result = WinWait($title,$text,$timeout)
if $result = False Then
MsgBox(16,"Bad...","Window not displayed")
If Not WinActive($title,$text) Then WinActivate($title,$text)
Sleep(1000) ; sleep for 1s
CHECK MouseMove(@DesktopWidth/2, @DesktopHeight/2)
(only as last resort)
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
More information here.
To set or refer to the content of a variable: (Const/Global/Local/Dim) $myvar = "test"
To refer to environment variables: @ComputerName
To require explicit declaration of variables: Opt("MustDeclareVars", 1)
To include files: #include <myfile.au3>
To include an external file into the AutoIT output EXE à la NSIS: FileInstall(Source,Destination[,flag])
The array.au3 UDF offers extended functions to handle arrays, eg. _ArrayDisplay($myarray)
For $index=1 to 1
To pause for one second:
To run a desktop shortcut:
The Send() function sends a string to whatever window is active, ie. it's not possible to tell it to only send data to a specific window. So if you're using a loop, add a WinWaitActive() to make sure you're no sending stuff in a totally different window:
You must use "&", not "+":
Here's how to clear the clipboard, and copy data to it:
The PCRE regex engine that AutoIT uses is single-line by default. If you need to find a pattern in a multi-line string, you must tell PCRE explicitely:
There is apparently no way to configure PCRE externely for the duration of a script, ie. without adding settings to every single pattern.
Here's how to extract the second part in a two-item string with a TAB delimiter:
AutoIT can be used to write graphical applications. As of Oct 2010, there are two ways to do this: Either directly, or by using the Koda GUI designer.
myscript..au3 (1) : ==> Unknown function name.: _WinWaitActivate("classname=TfrmPref","")
If you just copy/paste the output instead of what's actually saved in a file, you'll be missing some User-defined functions (UDF) that Au3Record relies on:
There is a bug with release 3.3 which uses "classname=myclass" instead of "[CLASS:myclass]".
AHK is Faster, has simpler hotkey/hotstring definitions, low level hacks, and is open-source.