AutoItのロゴ | |
登場時期 | 1999年 |
---|---|
設計者 | Jonathan Bennett & AutoIt Team |
最新リリース | 3.3.16.1/ 2022年9月19日[1] |
主な処理系 | AutoIt3 |
ライセンス | フリーウェア |
ウェブサイト | www.autoitscript.com |
拡張子 | .au3 |
AutoIt(オートイット)はWindows用のプログラミング言語である。
AutoItはWindows用プログラムのGUI自動操作機能を主な特徴としている。スクリプトは実行形式にコンパイル可能であり、コンパイルしたものはAutoItインタプリタのインストールされていない環境でも動作する。フリーウェアであり非常に多くのライブラリ、開発ツールが存在する。
AutoItはもともとはGPLライセンスの下でソースコードの公開をおこなっていたが、現在はソースコードの公開は中止されている。これは別プロジェクトが繰り返しAutoItのソースコードを取り込んだ上でAutoItに対して敵対的な行動をとったため、と説明されている[2]。
; メッセージボックスに "Hello, world!" と表示して終了。
MsgBox(0, "Title", "Hello, world!")
Exit
; ユーザーが入力した数値の平均を求める
; 数値はカンマ(",")で区切られていなければならない
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <Array.au3>
#region---------------GUI-----------------------
$form = GUICreate("平均計算", 300, 75)
$label = GUICtrlCreateLabel("平均を計算する数値をカンマ("","")で区切って入力", 20, 5)
$textbox = GUICtrlCreateInput("", 20, 20, 220)
$label1 = GUICtrlCreateLabel("=", 245, 20, 30, 20)
$ansLabel = GUICtrlCreateLabel("", 255, 20, 50, 20)
$button = GUICtrlCreateButton("平均を計算", 100, 45)
GUISetState(@SW_SHOW)
#endregion---------------END GUI-----------------------
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $button Then
If _findAvg(GUICtrlRead($textbox)) = "malform1" Then
GUICtrlSetData($ansLabel,"エラー")
Else
GUICtrlSetData($ansLabel, _findAvg(GUICtrlRead($textbox)))
EndIf
EndIf
WEnd
Func _findAvg($nums)
Local $sData
Local $ans
;入力チェック----------------->
$chk = StringRight($nums, 5)
If $chk = "," Then $nums = StringTrimRight($nums, 1)
If StringInStr($nums, ",") < 1 Then
Return ("malform1")
EndIf
;----------------->
$sData = StringSplit($nums, ",")
$ans = 0
For $i = 1 To $sData[0]
$ans += $sData[$i]
Next
$ans = $ans / $sData[0]
Return ($ans)
EndFunc ;==>_findAvg
COMインターフェイス、DLLをサポートしているスクリプト言語、プログラミング言語向けにAutoItXというDLL形式ファイルが用意されている。AutoItXを使用することでAutoItの組み込み関数の一部を他の言語から使用することが可能である。
Perl
use Win32::OLE;
$oAutoIt = Win32::OLE->new("AutoItX3.Control");
$oAutoIt->Run("Notepad.exe", "");
Ruby
require 'win32ole'
oAutoIt = WIN32OLE.new('AutoItX3.Control')
oAutoIt.Run("Notepad.exe", "")
Python
import win32com.client
oAutoIt = win32com.client.Dispatch("AutoItX3.Control")
oAutoIt.Run("Notepad.exe", "")