rictirse 發表於 2012-9-23 17:17

Micro Duo教室之AutoIt 自動安裝開班授課 第二課

本帖最後由 rictirse 於 2014-12-24 08:37 編輯

學完第一課後對於AutoIt 的運作是不是有更一步的了解呢?

第一課使用模擬 快速鍵的方式來進行自動安裝

但是每台電腦的速度皆不同,安裝的時候容易遇到視窗AutoIt 已經可以抓到視窗的存在

但是繪圖尚未完成,也就是說在視窗還沒彈出時,AutoIt就已經輸入快速鍵

就會出現指令miss的情形出現,還好AutoIt 還有命中率、容錯率更高的指令可以使用

這邊一樣用 FileZilla_3.5.3_win32 作為教學範例

1.開頭一樣使用ShellExecute執行ShellExecute ("FileZilla_3.5.3_win32-setup.exe")
WinWaitActive ( "FileZilla Client 3.5.3 Setup", "Please review the license terms before installing FileZilla Client 3.5.3.")2.改用ControlClick 來達成
ControlClick ( "標題", "文字", 控制項ID [, 按鈕 [, 點選 [, x [, y ]]]] )

控制鍵ID 一樣是使用 Au3Info 來取得


ControlClick ( "FileZilla Client 3.5.3 Setup", "Please review the license terms before installing FileZilla Client 3.5.3.", "Button2")3.如果遇到 單選(RadioBox)或是複選(CheckBox)這時候用ControlClick 也是可以,但這邊教另一種指令ControlCommand

ControlCommand ( "標題", "文字", 控制項ID, "指令" [, "選項"] )WinWaitActive ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?")
ControlCommand ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button5", "Check", "")
ControlClick ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button2")

4.如果是想反選的話指令就是WinWaitActive ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.")
ControlCommand ("FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button4", "UnCheck", "");只要把Check 換成UnCheck 就是反選了
ControlClick ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button2")完整的安裝指令#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author:      Dang Wang

Script Function: FileZilla_Install
      Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

ShellExecute ("FileZilla_3.5.3_win32-setup.exe")

WinWaitActive ( "FileZilla Client 3.5.3 Setup", "Please review the license terms before installing FileZilla Client 3.5.3.")
ControlClick ( "FileZilla Client 3.5.3 Setup", "Please review the license terms before installing FileZilla Client 3.5.3.", "Button2")

WinWaitActive ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?")
ControlCommand ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button5", "Check", "")
ControlClick ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button2")

WinWaitActive ( "FileZilla Client 3.5.3 Setup", "Choose which features of FileZilla Client 3.5.3 you want to install.")
ControlClick ( "FileZilla Client 3.5.3 Setup", "Choose which features of FileZilla Client 3.5.3 you want to install.", "Button2")

WinWaitActive ( "FileZilla Client 3.5.3 Setup", "Choose the folder in which to install FileZilla Client 3.5.3.")
ControlClick ( "FileZilla Client 3.5.3 Setup", "Choose the folder in which to install FileZilla Client 3.5.3.", "Button2")

WinWaitActive ( "FileZilla Client 3.5.3 Setup", "Choose a Start Menu folder for the FileZilla Client 3.5.3 shortcuts.")
ControlClick ( "FileZilla Client 3.5.3 Setup", "Choose a Start Menu folder for the FileZilla Client 3.5.3 shortcuts.", "Button2")

WinWaitActive ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.")
ControlCommand ("FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button4", "UnCheck", "");只要把Check 換成UnCheck 就是反選了
ControlClick ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button2")
頁: [1]
查看完整版本: Micro Duo教室之AutoIt 自動安裝開班授課 第二課