关于AutoIT

来源:互联网 发布:日本的男装品牌 知乎 编辑:程序博客网 时间:2024/04/29 14:02

AutoIt设计初衷是对PC进行批量配置。后来以为其简单,轻量级的特点,多用于设计重复工作脚本。

以下是一些函数的具体用法code…

GUI界面:

;gui#include <GUIConstantsEx.au3>Func GetConvertXMLName()    Local $file, $btn, $msg, $input    GUICreate("Please select convert XML:", 390, 80, @DesktopWidth / 2 - 200, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES       $file = GUICtrlCreateCombo("Loader\Scripts\FullQAImportLoaderScript.xml", 20, 22, 280, 25, 0x0003) ; create first item    GUICtrlSetData(-1, "Loader\Scripts\MDSLoaderScript.xml", "Loader\Scripts\FullQAImportLoaderScript.xml") ; add other item snd set a new default    $btn = GUICtrlCreateButton("OK", 310, 20, 70, 25)    GUISetState()    $msg = 0    While $msg <> $GUI_EVENT_CLOSE        $msg = GUIGetMsg()        Select            Case $msg = $btn                ExitLoop        EndSelect    WEnd    If $msg = $GUI_EVENT_CLOSE Then Exit    $input = GUICtrlRead($file)    GUIDelete()    Return $inputEndFunc

热键:

HotKeySet("{Esc}", "captureEsc")Func captureEsc()   If MsgBox(4,"","Do you really want to quit?") = 6 Then ExitEndFunc

文件操作:

Local $search = FileFindFirstFile($Dir&"*")While 1   Local $file = FileFindNextFile($search)   If @error Then ExitLoop   Sleep (1000)WEnd

正则表达式:

$file = StringRegExp($read, '<File>\\'&StringRegExpReplace($input, "Script.xml", "")&'\\(.*?)</File>', 3)$R = StringRegExpReplace($IntanceName, ".xml", "")

对控件操作:

ControlClick("[ New ]", "", "WindowsForms10.BUTTON.app.0.2bf8098_r11_ad17")Send($fileName[0])Sleep (1000)WinWait("[ New ]")If Not WinActive("[ New ]","") Then WinActivate("[ New ]","")ControlSetText("[ New ]", "", "WindowsForms10.RichEdit20W.app.0.2bf8098_r11_ad11", $read)

AutoIt的官方文档写的特别详细一些函数自带demo实现,特别适合新手上手。

4 0
原创粉丝点击