請選擇 進入手機版 | 繼續訪問電腦版

微剋多資訊

 找回密碼
 註冊

Login

搜索

該用戶從未簽到

發表於 2012-9-23 17:48 | 顯示全部樓層 |閱讀模式
本帖最後由 rictirse 於 2012-11-5 23:45 編輯

學完第二課的你,應該算是一個可以自己撰寫一個相當效率的自動安裝程序了

但是噹噹還有隱藏的一手,只有在Micro Duo 才能看到的自動安裝手段

不僅效能相當高,準確率又比ControlClick高出不少,就是用噹噹自己寫的UDF(user defined function)

首先將下面三個func 貼到AutoIt Script 最下面
[code=autoit]Func _WinWaitClick ( $Title, $Text, $ControlID, $Sleep = 0)
        WinWait ( $Title, $Text)
        $handle = WinGetHandle ( $Title, $Text)
        Do
                ControlClick  ( $handle, "", $ControlID)
                Sleep ($Sleep)
        Until WinGetHandle ( $Title, $Text) <> $handle
EndFunc

Func _WinWaitCheck ( $Title, $Text, $ControlID, $Sleep = 0)
        WinWait ( $Title, $Text)
        $handle = WinGetHandle ( $Title, $Text)
        Do
                ControlCommand  ( $handle, "", $ControlID, "Check", "")
                Sleep ($Sleep)
        Until ControlCommand  ( $handle, "", $ControlID, "IsChecked", "")
EndFunc

Func _WinWaitUnCheck ( $Title, $Text, $ControlID, $Sleep = 0)
        WinWait ( $Title, $Text)
        $handle = WinGetHandle ( $Title, $Text)
        Do
                ControlCommand  ( $handle, "", $ControlID, "UnCheck", "")
                Sleep ($Sleep)
        Until ControlCommand  ( $handle, "", $ControlID, "IsChecked", "") = 0
EndFunc[/code]跟一、二課用一樣的FileZilla_3.5.3_win32 範例

1.開頭一樣使用ShellExecute執行[code=autoit]ShellExecute ("FileZilla_3.5.3_win32-setup.exe")
[/code]2.改用ControlClick 來達成
_WinWaitClick ( "標題", "文字", 控制項ID ,[延遲時間 預設 0秒])

很簡單的動作就可以換上噹噹的UDF

再把#19列的 [code=autoit]ControlCommand ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button5", "Check", "")
置換成
_WinWaitCheck ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button5")[/code]與#32列的[code=autoit]ControlCommand ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button4", "UnCheck", "")
置換成
_WinWaitUnCheck ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button4") [/code]再把全部的WinWaitActive與其引數完全刪除後的Script[code=autoit]#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")

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

_WinWaitCheck ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button5")
_WinWaitClick ( "FileZilla Client 3.5.3 Setup", "Who should this application be installed for?", "Button2")

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

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

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

_WinWaitUnCheck (  "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button4")
_WinWaitClick ( "FileZilla Client 3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on your computer.", "Button2")

Func _WinWaitClick ( $Title, $Text, $ControlID, $Sleep = 0)
        WinWait ( $Title, $Text)
        $handle = WinGetHandle ( $Title, $Text)
        Do
                ControlClick  ( $handle, "", $ControlID)
                Sleep ($Sleep)
        Until WinGetHandle ( $Title, $Text) <> $handle
EndFunc

Func _WinWaitCheck ( $Title, $Text, $ControlID, $Sleep = 0)
        WinWait ( $Title, $Text)
        $handle = WinGetHandle ( $Title, $Text)
        Do
                ControlCommand  ( $handle, "", $ControlID, "Check", "")
                Sleep ($Sleep)
        Until ControlCommand  ( $handle, "", $ControlID, "IsChecked", "")
EndFunc

Func _WinWaitUnCheck ( $Title, $Text, $ControlID, $Sleep = 0)
        WinWait ( $Title, $Text)
        $handle = WinGetHandle ( $Title, $Text)
        Do
                ControlCommand  ( $handle, "", $ControlID, "UnCheck", "")
                Sleep ($Sleep)
        Until ControlCommand  ( $handle, "", $ControlID, "IsChecked", "") = 0
EndFunc[/code]

本帖子中包含更多資源

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

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

本版積分規則

Discuz! X

© 2009-2017 Microduo

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