微剋多資訊

 找回密碼
 註冊

Login

Login

搜索

該用戶從未簽到

發表於 2012-9-23 17:17 | 顯示全部樓層 |閱讀模式
本帖最後由 rictirse 於 2014-12-24 08:37 編輯

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

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

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

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

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

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

1.開頭一樣使用ShellExecute執行
  1. ShellExecute ("FileZilla_3.5.3_win32-setup.exe")
  2. 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 來取得


  1. 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, "指令" [, "選項"] )
[code=autoit]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")[/code]

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

  2. AutoIt Version: 3.3.8.1
  3. Author:        Dang Wang

  4. Script Function: FileZilla_Install
  5.         Template AutoIt script.

  6. #ce ----------------------------------------------------------------------------

  7. ; Script Start - Add your code below here

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

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

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

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

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

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

  20. WinWaitActive ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.")
  21. ControlCommand (  "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button4", "UnCheck", "");只要把Check 換成UnCheck 就是反選了
  22. ControlClick ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button2")
複製代碼

本帖子中包含更多資源

您需要 登入 才可以下載或查看,沒有帳號?註冊

x
您需要登入後才可以回帖 登入 | 註冊

本版積分規則

小黑屋|Archiver|微剋多資訊(MicroDuo)

GMT+8, 2016-12-11 10:08

Discuz! X

© 2009-2016 Microduo

快速回覆 返回頂部 返回列表