Jump to content

AutoIt: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Fixed date
m Removing link(s) Wikipedia:Articles for deletion/ThinBasic closed as soft delete (XFDcloser)
 
(13 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{short description|Scripting language to automate tasks in Microsoft Windows}}
{{Infobox programming language
{{Infobox programming language
| name = AutoIt
| name = AutoIt
Line 6: Line 7:
| designer = Jonathan Bennett
| designer = Jonathan Bennett
| developer = AutoIt Consulting Ltd.
| developer = AutoIt Consulting Ltd.
| paradigm = [[object-oriented programming|Object-oriented]], [[imperative programming|imperative]], [[functional programming|functional]], [[procedural programming|procedural]], [[reflective programming|reflective]]
| paradigm = [[imperative programming|imperative]], [[functional programming|functional]], [[procedural programming|procedural]], [[reflective programming|reflective]]
| released = {{Release date and age|1999|01}}
| released = {{Release date and age|1999|01}}
| latest_release_version = 3.3.16.1
| latest_release_version = 3.3.16.1
| latest_release_date = {{Release date and age|2022|09|19}}<ref>{{cite web|url=https://www.autoitscript.com/site/autoit/downloads/| publisher=AutoIt| title=AutoIt Downloads| access-date=2022-11-07}}</ref>
| latest_release_date = {{Release date and age|2022|09|19}}<ref>{{Cite web |title=AutoIt Downloads |url=https://www.autoitscript.com/site/autoit/downloads/ |access-date=2022-11-07 |publisher=AutoIt}}</ref>
| latest_preview_version = 3.3.16.1 [[Release candidate|RC]]
| latest_preview_version = 3.3.16.1 [[Release candidate|RC]]2
| latest_preview_date = {{Release date and age|2022|06|02}}<ref>{{cite web|url=https://www.autoitscript.com/forum/topic/208263-autoit-33161-release-candidate/| title=AutoIt 3.3.16.1 Release Candidate| publisher=AutoIt| access-date=2022-06-08}}</ref>
| latest_preview_date = {{Release date and age|2022|06|09}}<ref>{{Cite web |title=AutoIt 3.3.16.1 Release Candidate | date=2 June 2022 |url=https://www.autoitscript.com/forum/topic/208263-autoit-33161-release-candidate/?do=findComment&comment=1503008 |access-date=2022-11-07 |publisher=AutoIt}}</ref>
| influenced by = [[BASIC]]
| influenced by = [[BASIC]]
| programming language = <!--Citation is needed to add this-->
| programming language = <!--Citation is needed to add this-->
Line 21: Line 22:
}}
}}


'''AutoIt''' {{IPAc-en|ɔː|t|oʊ|_|ɪ|t}}<ref>[https://www.autoitscript.com/forum/index.php?s=&showtopic=22349&view=findpost&p=155491 Reply by Jon (AutoIt creator) to a forum topic discussing correct pronunciation]{{dead link|date=October 2016 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> is a [[freeware]] [[programming language]] for [[Microsoft Windows]]. In its earliest release, it was primarily intended to create [[automation]] scripts (sometimes called [[Macro (computer science)|macros]]) for Microsoft Windows programs<ref name="Kaplan000">{{cite book | last = Kaplan | first = Steve | title = Citrix Metaframe Access Suite for Windows Server 2003 | publisher = McGraw-Hill | location = New York | year = 2003 | isbn = 0-07-219566-5 }}</ref> but has since grown to include enhancements in both programming language design and overall functionality.
'''AutoIt''' {{IPAc-en|ɔː|t|oʊ|_|ɪ|t}}<ref>{{Cite web |title=Reply by Jon (AutoIt creator) to a forum topic discussing correct pronunciation |url=https://www.autoitscript.com/forum/index.php?s=&showtopic=22349&view=findpost&p=155491 }}{{Dead link|date=August 2023 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> is a [[freeware]] [[programming language]] for [[Microsoft Windows]]. In its earliest release, it was primarily intended to create [[automation]] scripts (sometimes called [[Macro (computer science)|macros]]) for Microsoft Windows programs<ref name="Kaplan000">{{Cite book |last=Kaplan |first=Steve |title=Citrix Metaframe Access Suite for Windows Server 2003 |publisher=McGraw-Hill |year=2003 |isbn=0-07-219566-5 |location=New York}}</ref> 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 type|variant data type]] that can store several types of data, including arrays.
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 type|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 (known as UDFs, or "User Defined Functions")<ref>{{cite web| url=https://www.autoitscript.com/wiki/User_Defined_Functions| title=User Defined Functions| publisher=AutoIt| date=2021-06-22| accessdate=2021-07-16}}</ref> are also included as standard or are available from the website to add specialized functionality. AutoIt is also distributed with an [[Integrated development environment|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.
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 (known as UDFs, or "User Defined Functions")<ref>{{Cite web |date=2021-06-22 |title=User Defined Functions |url=https://www.autoitscript.com/wiki/User_Defined_Functions |access-date=2021-07-16 |publisher=AutoIt}}</ref> are also included as standard or are available from the website to add specialized functionality. AutoIt is also distributed with an [[Integrated development environment|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.


==History==
==History==
Line 48: Line 49:
| 2014a = June: AutoIt v3.3.12.0 released
| 2014a = June: AutoIt v3.3.12.0 released
| 2015a = July: AutoIt v3.3.14.0 and v3.3.14.1 released
| 2015a = July: AutoIt v3.3.14.0 and v3.3.14.1 released
| 2015b = September: AutoIt v3.3.14.2 released<ref>{{Cite web|url=https://www.autoitscript.com/autoit3/docs/history.htm|title=AutoIt History|website=www.autoitscript.com|access-date=2016-04-19}}</ref>
| 2015b = September: AutoIt v3.3.14.2 released<ref>{{Cite web |title=AutoIt History |url=https://www.autoitscript.com/autoit3/docs/history.htm |access-date=2016-04-19 |website=www.autoitscript.com}}</ref>
| 2018a = February: AutoIt v3.3.14.3 released<ref>[https://www.autoitscript.com/site/autoit-news/autoit-v3-3-14-3-released/ AutoIt v3.3.14.3 Released Feb 2, 2018]</ref>
| 2018a = February: AutoIt v3.3.14.3 released<ref>{{Cite web |last=Bennett |first=Jonathan |date=February 2, 2018 |title=AutoIt v3.3.14.3 Released |url=https://www.autoitscript.com/site/autoit-news/autoit-v3-3-14-3-released/}}</ref>
| 2018b = March: AutoIt v3.3.14.5 released<ref>[https://www.autoitscript.com/site/autoit-news/autoit-v3-3-14-5-released/ AutoIt v3.3.14.5 Released March 16, 2018]</ref>
| 2018b = March: AutoIt v3.3.14.5 released<ref>{{Cite web |last=Bennett |first=Jonathan |date=March 16, 2018 |title=AutoIt v3.3.14.5 Released |url=https://www.autoitscript.com/site/autoit-news/autoit-v3-3-14-5-released/}}</ref>
| 2022a = March: AutoIt v3.3.16.0 released
| 2022b = September: AutoIt v3.3.16.1 released
}}
}}
</div>
</div>
AutoIt1 and AutoIt2 were closed-source projects, and had a very different syntax than AutoIt3, whose syntax is more like [[VBScript]] and BASIC.<ref>{{Cite web|url=http://www.autoitscript.com:80/autoit3/index.php|archive-url = https://web.archive.org/web/20050211013725/http://www.autoitscript.com:80/autoit3/index.php|archive-date = 2005-02-11|title = AutoIt Scripting Language}}</ref>
AutoIt1 and AutoIt2 were closed-source projects, and had a very different syntax than AutoIt3, whose syntax is more like [[VBScript]] and BASIC.<ref>{{Cite web |title=AutoIt Scripting Language |url=http://www.autoitscript.com:80/autoit3/index.php |archive-url=https://web.archive.org/web/20050211013725/http://www.autoitscript.com:80/autoit3/index.php |archive-date=2005-02-11}}</ref>


AutoIt3 was initially [[free and open-source]], licensed under the terms of the [[GNU General Public License]],<ref>{{cite web | url=https://www.autoitscript.com/forum/topic/7204-licensing-opinions/ | title=Licensing Opinions | date=2005-05-02 | website=AutoIt | quote=The GPL license was chosen as it is generally accepted as the most restrictive | access-date=2018-10-05}}</ref><ref>{{cite web | archive-url=https://web.archive.org/web/20050104172743/https://www.autoitscript.com/autoit3/docs/license.htm | archive-date=2005-01-04 | date=2014-03-25 | url=https://www.autoitscript.com/autoit3/docs/license.htm | title=License | quote=AutoIt is copyrighted software distributed under the terms of the GNU General Public License (hereinafter the "GPL") | access-date=2018-10-05 }}</ref> with its initial public release 3.0.100 in February 2004,<ref>https://www.autoitscript.com/autoit3/files/archive/autoit/autoit-v3.0.100.zip {{Bare URL non-HTML|date=August 2022}}</ref> and had open-source releases in March 2004 and August 2004. Version 3.0.102, released in August 2004, was initially open-source, but by January 2005 was distributed as closed-source.<ref>{{Cite web|url=http://www.autoitscript.com:80/autoit3/docs/|archive-url=https://web.archive.org/web/20050206105706/http://www.autoitscript.com:80/autoit3/docs/|archive-date=2005-02-06|title=AutoIt}}</ref> Subsequent releases, starting from the February 2005 release of version 3.1.0, were all closed-source. Version 3.1.0 was also the first release with support for GUI scripts.
AutoIt3 was initially [[free and open-source]], licensed under the terms of the [[GNU General Public License]],<ref>{{Cite web |date=2005-05-02 |title=Licensing Opinions |url=https://www.autoitscript.com/forum/topic/7204-licensing-opinions/ |access-date=2018-10-05 |website=AutoIt |quote=The GPL license was chosen as it is generally accepted as the most restrictive}}</ref><ref>{{Cite web |date=2014-03-25 |title=License |url=https://www.autoitscript.com/autoit3/docs/license.htm |archive-url=https://web.archive.org/web/20050104172743/https://www.autoitscript.com/autoit3/docs/license.htm |archive-date=2005-01-04 |access-date=2018-10-05 |quote=AutoIt is copyrighted software distributed under the terms of the GNU General Public License (hereinafter the "GPL")}}</ref> with its initial public release 3.0.100 in February 2004,<ref>{{Cite web |title=Index of /autoit3/files/archive/autoit |url=https://www.autoitscript.com/autoit3/files/archive/autoit/ |access-date=2022-11-17 |website=www.autoitscript.com}}</ref> and had open-source releases in March 2004 and August 2004. Version 3.0.102, released in August 2004, was initially open-source, but by January 2005 was distributed as closed-source.<ref>{{Cite web |title=AutoIt |url=http://www.autoitscript.com:80/autoit3/docs/ |archive-url=https://web.archive.org/web/20050206105706/http://www.autoitscript.com:80/autoit3/docs/ |archive-date=2005-02-06}}</ref> Subsequent releases, starting from the February 2005 release of version 3.1.0, were all closed-source. Version 3.1.0 was also the first release with support for GUI scripts.


=== Related projects ===
=== Related projects ===


The free and open-source [[AutoHotkey]] project derived 29 of its functions from the AutoIt 3.1 source code.<ref>[https://autohotkey.com/board/topic/2916-three-thumbs-up/#entry18972 Chris Mallet (author of AutoHotkey)'s post]</ref> The AutoHotkey syntax is quite different from AutoIt3 syntax, and rather resembles AutoIt2 syntax.
The free and open-source [[AutoHotkey]] project derived 29 of its functions from the AutoIt 3.1 source code.<ref>{{Cite web |title=Three thumbs up! - Offtopic |url=http://www.autohotkey.com/board/topic/2916-three-thumbs-up/ |website=AutoHotkey Community}}</ref> The AutoHotkey syntax is quite different from AutoIt3 syntax, and rather resembles AutoIt2 syntax.


==Features==
==Features==
Line 65: Line 68:
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.
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.


AutoIt can also be used in [[Laboratory automation#Low-cost laboratory automation|low-cost laboratory automation]]. Applications include instrument synchronization, alarm monitoring and results gathering. Devices such as CNC routers and 3D-printers can also be controlled.<ref name="CheapLab">{{cite book|title=Practical Laboratory Automation: Made Easy with AutoIt|last=Carvalho|first=Matheus C.|publisher=Wiley V|date=March 2016|isbn=978-3-527-34158-0|pages=5–7|id=Topics Covered in this Book}}</ref>
AutoIt can also be used in [[Laboratory automation#Low-cost laboratory automation|low-cost laboratory automation]]. Applications include instrument synchronization, alarm monitoring and results gathering. Devices such as CNC routers and 3D-printers can also be controlled.<ref name="CheapLab">{{Cite book |last=Carvalho |first=Matheus C. |title=Practical Laboratory Automation: Made Easy with AutoIt |date=March 2016 |publisher=Wiley V |isbn=978-3-527-34158-0 |pages=5–7 |id=Topics Covered in this Book}}</ref>


* 64-bit code support from version 3.2.10.0
* Scripting language with BASIC-like structure for Windows
* Compiling into standalone executables
* Add-on libraries and modules for specific apps
* Add-on libraries and modules for specific apps
* Automate sending user input and keystrokes to apps, as well as to individual controls within an app
* Supports [[Transmission Control Protocol|TCP]] and [[User Datagram Protocol|UDP]] protocols
* Supports [[component object model]] (COM)
* Call functions in [[Dynamic-link library|DLL files]]
* Call functions in [[Dynamic-link library|DLL files]]
* Compatible with [[User Account Control]]
* Run console apps and access the [[standard streams]]
* Compiling into standalone executables
* Create [[graphical user interface]]s, including message and input boxes
* Include data files in the compiled file to be extracted when running
* Include data files in the compiled file to be extracted when running
* Manipulate windows and processes
* Create [[graphical user interface]]s, including message and input boxes
* [[Object-oriented]] design through a library<ref>{{Cite web |date=February 26, 2010 |title=AutoitObject. a library to use object-oriented design in autoit |url=http://autoitobject.origo.ethz.ch |archive-url=https://web.archive.org/web/20100226105014/http://autoitobject.origo.ethz.ch/ |archive-date=2010-02-26 |access-date=2021-07-16}}</ref>
* Play sounds, pause, resume, stop, seek, get the current position of the sound and get the length of the sound
* Play sounds, pause, resume, stop, seek, get the current position of the sound and get the length of the sound
* Run console apps and access the [[standard streams]]
* Scripting language with BASIC-like structure for Windows
* Simulate [[Mouse (computing)|mouse]] movements
* Simulate [[Mouse (computing)|mouse]] movements
* Supports [[component object model]] (COM)
* Manipulate windows and processes
* Automate sending user input and keystrokes to apps, as well as to individual controls within an app
* Unicode support from version 3.2.4.0
* 64-bit code support from version 3.2.10.0
* Supports [[regular expressions]]
* Supports [[regular expressions]]
* Supports [[Transmission Control Protocol|TCP]] and [[User Datagram Protocol|UDP]] protocols
* Compatible with [[User Account Control]]
* Unicode support from version 3.2.4.0
* [[Object-oriented]] design through a library<ref>{{cite web| url=http://autoitobject.origo.ethz.ch| title=AutoitObject. a library to use object-oriented design in autoit| archive-url=https://web.archive.org/web/20100226105014/http://autoitobject.origo.ethz.ch/| archive-date=2010-02-26 |date=February 26, 2010| accessdate=2021-07-16}}</ref>


==Examples==
==Examples==
Line 194: Line 197:
* [[Automator (software)|Automator]] (for Macintosh)
* [[Automator (software)|Automator]] (for Macintosh)
* [[Expect]]
* [[Expect]]
* [[iMacros]]
* [[Keyboard Maestro]] (for Macintosh)
* [[Keyboard Maestro]] (for Macintosh)
* [[KiXtart]]
* [[KiXtart]]
* [[iMacros]]
* [[Macro Express]]
* [[Macro Express]]
* [[thinBasic]]
* [[Winbatch]]
* [[Winbatch]]



Latest revision as of 23:17, 10 November 2024

AutoIt
Paradigmimperative, functional, procedural, reflective
Designed byJonathan Bennett
DeveloperAutoIt Consulting Ltd.
First appearedJanuary 1999; 25 years ago (1999-01)
Stable release
3.3.16.1 / September 19, 2022; 2 years ago (2022-09-19)[1]
Preview release
3.3.16.1 RC2 / June 9, 2022; 2 years ago (2022-06-09)[2]
PlatformIA-32 and x64
OSWindows XP SP3 and later
Windows Server 2003 and later
LicenseFreeware
Filename extensions.au3
Websitewww.autoitscript.com
Influenced by
BASIC

AutoIt /ɔːt ɪt/[3] is a freeware programming language for Microsoft Windows. In its earliest release, it was primarily intended to create automation scripts (sometimes called macros) for Microsoft Windows programs[4] 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 (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.

History

[edit]
Release timeline
1999January: First AutoIt Version (1.0)
August: AutoIt v2 and AutoItX
September: First AutoIt version with Compiler
2000
2001
2002December: AutoIt v3 (Public Beta)
2003
2004February: AutoIt v3 (Stable)
2005
2006September: Auto3Lib started
2007November: AutoIt v3.2.10.0 released, Auto3Lib incorporated into AutoIt v3
2008May: AutoIt v3.2.12.0 released, incorporating added GUI functionality
December: AutoIt (and AutoItX) v3.3.0.0 released
2009December: AutoIt v3.3.2.0 released
2010January: AutoIt v3.3.4.0 released
March: AutoIt v3.3.6.0 released
April: AutoIt v3.3.6.1 released
2011December: AutoIt v3.3.8.0 released
2012January: AutoIt v3.3.8.1 released
2013December: AutoIt v3.3.10.0 released
2014June: AutoIt v3.3.12.0 released
2015July: AutoIt v3.3.14.0 and v3.3.14.1 released
September: AutoIt v3.3.14.2 released[6]
2016
2017
2018February: AutoIt v3.3.14.3 released[7]
March: AutoIt v3.3.14.5 released[8]
2019
2020
2021
2022March: AutoIt v3.3.16.0 released
September: AutoIt v3.3.16.1 released

AutoIt1 and AutoIt2 were closed-source projects, and had a very different syntax than AutoIt3, whose syntax is more like VBScript and BASIC.[9]

AutoIt3 was initially free and open-source, licensed under the terms of the GNU General Public License,[10][11] with its initial public release 3.0.100 in February 2004,[12] and had open-source releases in March 2004 and August 2004. Version 3.0.102, released in August 2004, was initially open-source, but by January 2005 was distributed as closed-source.[13] Subsequent releases, starting from the February 2005 release of version 3.1.0, were all closed-source. Version 3.1.0 was also the first release with support for GUI scripts.

[edit]

The free and open-source AutoHotkey project derived 29 of its functions from the AutoIt 3.1 source code.[14] The AutoHotkey syntax is quite different from AutoIt3 syntax, and rather resembles AutoIt2 syntax.

Features

[edit]
AU3 File Format Icon

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.

AutoIt can also be used in low-cost laboratory automation. Applications include instrument synchronization, alarm monitoring and results gathering. Devices such as CNC routers and 3D-printers can also be controlled.[15]

  • 64-bit code support from version 3.2.10.0
  • Add-on libraries and modules for specific apps
  • Automate sending user input and keystrokes to apps, as well as to individual controls within an app
  • Call functions in DLL files
  • Compatible with User Account Control
  • Compiling into standalone executables
  • Create graphical user interfaces, including message and input boxes
  • Include data files in the compiled file to be extracted when running
  • Manipulate windows and processes
  • Object-oriented design through a library[16]
  • Play sounds, pause, resume, stop, seek, get the current position of the sound and get the length of the sound
  • Run console apps and access the standard streams
  • Scripting language with BASIC-like structure for Windows
  • Simulate mouse movements
  • Supports component object model (COM)
  • Supports regular expressions
  • Supports TCP and UDP protocols
  • Unicode support from version 3.2.4.0

Examples

[edit]

Hello world

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

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

Automating the Windows Calculator

[edit]
; 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

[edit]
; 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

See also

[edit]

References

[edit]
  1. ^ "AutoIt Downloads". AutoIt. Retrieved 2022-11-07.
  2. ^ "AutoIt 3.3.16.1 Release Candidate". AutoIt. 2 June 2022. Retrieved 2022-11-07.
  3. ^ "Reply by Jon (AutoIt creator) to a forum topic discussing correct pronunciation".[permanent dead link]
  4. ^ Kaplan, Steve (2003). Citrix Metaframe Access Suite for Windows Server 2003. New York: McGraw-Hill. ISBN 0-07-219566-5.
  5. ^ "User Defined Functions". AutoIt. 2021-06-22. Retrieved 2021-07-16.
  6. ^ "AutoIt History". www.autoitscript.com. Retrieved 2016-04-19.
  7. ^ Bennett, Jonathan (February 2, 2018). "AutoIt v3.3.14.3 Released".
  8. ^ Bennett, Jonathan (March 16, 2018). "AutoIt v3.3.14.5 Released".
  9. ^ "AutoIt Scripting Language". Archived from the original on 2005-02-11.
  10. ^ "Licensing Opinions". AutoIt. 2005-05-02. Retrieved 2018-10-05. The GPL license was chosen as it is generally accepted as the most restrictive
  11. ^ "License". 2014-03-25. Archived from the original on 2005-01-04. Retrieved 2018-10-05. AutoIt is copyrighted software distributed under the terms of the GNU General Public License (hereinafter the "GPL")
  12. ^ "Index of /autoit3/files/archive/autoit". www.autoitscript.com. Retrieved 2022-11-17.
  13. ^ "AutoIt". Archived from the original on 2005-02-06.
  14. ^ "Three thumbs up! - Offtopic". AutoHotkey Community.
  15. ^ Carvalho, Matheus C. (March 2016). Practical Laboratory Automation: Made Easy with AutoIt. Wiley V. pp. 5–7. ISBN 978-3-527-34158-0. Topics Covered in this Book.
  16. ^ "AutoitObject. a library to use object-oriented design in autoit". February 26, 2010. Archived from the original on 2010-02-26. Retrieved 2021-07-16.
[edit]