本帖最後由 gary8349 於 2013-2-15 17:09 編輯
~~~補上遺失的樓層~~~
bee:
================================================================ 請問版主:
執行時停於 line 28: Send ("!i")
等待按 install 是否正確?
以後 的 finish 會正常執行,
而且自動開啟檔案! ================================================================
rictirse: Re:bee
================================================================ 不太懂你的意思 WinWaitActive ( "FileZilla Client 3.5.3 Setup","Choose a Start Menu folder for the FileZilla Client 3.5.3shortcuts.") ;這個是等待 視窗出現的指令 Send ("!i") ;當 上面的視窗出現以後 才會輸入 alt + i 的這個 快速鍵指令 有問題再提出來吧~~ ================================================================
ken670128: Re:bee
================================================================ Send 命令,只要視窗一脫離現用視窗(焦點)或者系統較繁忙時,就會變成沒按到而卡在那邊
即便你沒有自己動到鍵盤滑鼠,但一些背景程式有時會影響到,解決方式可用 Do...Until 或視窗元件控制命令( Controlxxxxxx...等 )
自動開啟檔案 & 安裝廣告元件 <== 這通常在自動安裝時要取消核取,可利用 ControlCommand 命令,用法請參考 Autoit 本身內建的說明
Autoit 本身內建的說明非常完整,當初我學習 Autoit時沒有像現在有那麼多資訊可取得,更加別說有中文資訊了,完全是靠內建說明一步一步學起來的
先提醒一下,基本上FileZilla_3.5.3_win32-setup.exe 有自動安裝的參數 /S,可以不需使用 Autoit 來寫自動安裝,不過可以拿來作為學習範例
剛剛特地去翻很久以前,我有用 Autoit 來自動安裝軟體時所燒錄的光碟片...
以下拿 Alcohol 120% v2.0.0.1331 作為範例,沒有新版的,因為現在沒有在用Autoit 做自動安裝
雖然這個源碼是以 Alcohol 120% 來撰寫,但當時我都把這架構視為模版,稍作修改就直接套用在別的軟體上 [code=autoit]Opt("TrayIconHide", 1)
環境設定
;====================================================================================================================================
; 安裝檔名稱
$InstFile = "Alcohol120_retail_2.0.0.1331.exe"
; 安裝檔標題
$InstTitle = "Alcohol 120% 2.0.0.1331"
$PatchTitle = "Setup - PatCh Alcohol 120% 1.9.8.x - 2.0.0.x Retail"
; 開始功能表名稱
$SMenuName = "Alcohol 120%"
; 程式分類目錄
$Catagory = "工具程式\光碟工具\光碟應用工具"
; 登錄檔預先設定
Local $hklmkey = "HKLM\Software\Alcohol Soft\Alcohol 120%"
Local $hkcukey = "HKCU\Software\Alcohol Soft\Alcohol 120%"
RegWrite($hklmkey & "\AddRemove\Components\SecStarWind", "Installed", "REG_DWORD", "0")
; 執行腳本
;====================================================================================================================================
; 執行安裝程式
Run($InstFile)
; 等待安裝程式的頁面出現
WinWait($InstTitle)
; 移動安裝視窗到畫面外
WinMove($InstTitle, "", -50 , -50 , 0 , 0)
Do
Select
; 等待安裝程式的歡迎頁面出現
Case WinExists($InstTitle,"Welcome to the Alcohol 120% Setup Wizard")
; 按下一步
ControlClick($InstTitle,"Welcome to the Alcohol 120% Setup Wizard","Button2")
; 安裝程式的授權頁面出現
case WinExists($InstTitle,"License Agreement")
; 按 "I Agree"
ControlClick($InstTitle,"License Agreement","Button2")
; 安裝程式的選擇元件頁面出現
Case WinExists($InstTitle,"Choose Components")
; 按下一步
ControlClick($InstTitle,"Choose Components","Button2")
; 安裝程式的安裝路徑頁面出現
Case WinExists($InstTitle,"Choose Install Location")
; 取得 Edit1 控制項裏的安裝目錄,並把它存到 $path 變數中
$path = ControlGetText($InstTitle,"Choose Install Location","Edit1")
; 按安裝
ControlClick($InstTitle,"Choose Install Location","Button2")
; 安裝程式的完成頁面出現
Case WinExists($InstTitle,"Completing the Alcohol 120% Setup Wizard")
; 按 Finish 完成安裝
ControlCommand($InstTitle,"Completing the Alcohol 120% Setup Wizard","Button4","UnCheck","")
ControlClick($InstTitle,"Completing the Alcohol 120% Setup Wizard","Button2")
EndSelect
Until Not WinExists($InstTitle)
; 軟體個別設定
;====================================================================================================================================
; 登錄資訊
RegWrite($hkcukey & "\Options\General", "AutoCheckCurrentVersionViaInternetAtStart", "REG_SZ", "0")
RegDelete($hkcukey & "\Info")
RegDelete("HKCU\Software\StarSynergy")
Sleep(1000)
FileCopy("PatCh5122ML.exe",$path,9)
Run($path & "\" & "PatCh5122ML.exe",$path)
WinWait($PatchTitle)
WinMove($PatchTitle, "", -50 , -50 , 0 , 0)
Do
Select
; 等待安裝程式的歡迎頁面出現
Case WinExists($PatchTitle,"Welcome to the PatCh Alcohol 120% 1.9.8.x - 2.0.0.x Retail Setup Wizard")
; 按下一步
ControlClick($PatchTitle,"Welcome to the PatCh Alcohol 120% 1.9.8.x - 2.0.0.x Retail Setup Wizard","TNewButton1")
EndSelect
Until Not WinExists($PatchTitle)
Sleep(2000)
RegWrite($hkcukey & "\Options", "Language", "REG_SZ", "1028")
RegWrite($hkcukey & "\Info", "UserName", "REG_SZ", "User")
RegWrite($hkcukey & "\Info", "Serverkey", "REG_SZ", "ALBM3P4TVV96BM3T8M3T8BCDFDFPQXYC3YBV98YQRBBCDDD6B6B9QP4F6CDPQK2896KFGT82R9FBC6B342RDFT88967BC8P23MPJ9BCBCBCBCBCQR6")
[/code] ================================================================
bee:
================================================================ 就是停在我附的畫面上。
要等我 按 install 後才會繼續執行。
但我執行 Lesson 3 時,一鍵完成。
誠如 4樓 ken大 所言,應是 加了 Do...Until。
謝謝 二位回答,
更謝 4F ken大,又提供了一個好範例。 ================================================================
bee:
================================================================ 自動安裝-圖示說明:
安裝軟體更新頻繁,避免以後新學習者不容易找到該軟體,
小弟借花獻佛,以圖說輔助說明,其能讓新學習者有所了解!
檔案 FileZilla_3.5.3_win32-setup.exe 到這裡下載
圖顏色說明:自動安裝-第一課 採用紅色框,第二課採用藍色框
圖.1 - licenseterms Agree WinWaitActive ( "FileZilla Client 3.5.3Setup", "Please review the license terms before installing FileZillaClient 3.5.3.")
Send ("!a")
圖.2 -Choose Installation
WinWaitActive ( "FileZilla Client 3.5.3Setup", "Who should this application be installed for?")
Send ("!n")
自動安裝-第二課
ControlCommand ( "FileZilla Client 3.5.3Setup", "Who should this application be installed for?","Button5", "Check", "")
圖.3 -Choose Components
WinWaitActive ( "FileZilla Client 3.5.3Setup", "Choose which features of FileZilla Client 3.5.3 you want toinstall.")
Send ("!n") 圖.4 - Choose folder WinWaitActive ( "FileZilla Client 3.5.3Setup", "Choose the folder in which to install FileZilla Client3.5.3.")
Send ("!n")
圖.5 -Choose Start Menu
WinWaitActive ( "FileZilla Client 3.5.3Setup", "Choose a Start Menu folder for the FileZilla Client 3.5.3shortcuts.")
Send ("!i")
圖.6 -Finish
WinWaitActive ( "FileZilla Client 3.5.3Setup", "FileZilla Client 3.5.3 has been installed on yourcomputer.")
Send ("!f")
自動安裝-第二課
ControlCommand ( "FileZilla Client3.5.3 Setup", "FileZilla Client 3.5.3 has been installed on yourcomputer.", "Button4", "UnCheck", "")
最後留個引:
1. 自動更新每換版本,都要重新修改以上步驟,
不知有沒有一套軟體,能在安裝前執行,
紀錄每一安裝步驟後,就自動將程式寫好?
2. 如何取得 title、text 及 圖.2 第二課 Button5 的名稱?
================================================================
ken670128:
================================================================ 有別的可以錄製的工具軟體,也有自動生成 Autoit 源碼的錄製工具,因為我都有看到過,但都沒有使用過,所以無法跟你說好不好用,
因為軟體自動安裝,說真得用不太到 Autoit ,既使要用到,就如我先前所說的使用上面的源碼作模版,簡單修改幾行就可應用在別的
軟體上,實在不需再用額外的軟體去錄製
別的錄製工具軟體可以在 Google 搜看看
錄製 Autoit 源碼的工具可以去 Autoit 中文論壇 的軟件安裝區看看
剛去 IT 天空一看,斗大的標題「 i-Autoit-1.01正式版[自動安裝腳本輔助工具]」,看了一下似乎就是用來錄製用的~~
視窗標題、文字、控件名稱,可用安裝 Autoit 時所附的 AutoIt Window Info 工具來取得
第一課~第二課附的幾張圖中有教如何取得這些資訊的方式 ================================================================
bee:
================================================================ 5.每一台電腦執行速度不同,所以這邊要寫一個等待視窗出現的指令
WinWaitActive ( "標題" [, "文字" [, 逾時]] )
標題與文字可以直接使用AutoIt 內建的小工具Au3Info來查詢 怪小弟眼拙,沒發現到!
i-Autoit-1.01正式版[自動安裝腳本輔助工具 努力研讀!
謝謝 ken大 回覆! ==============================================================
================================================================ 一樣是 Alcohol1202.0.1.2033 的 install我之前也有寫過一個 英雄所見略同
因為途中需要重新開機,所以分為install_1 跟install_2
Install 2 重開機前 [code=autoit] $WindowsName = "Alcohol 120% 2.0.1.2033"
$Text_1 = "Click Next to continue."
$Text_2 = "If you accept the terms of the agreement, click I Agree to continue. You must accept the agreement to install Alcohol 120%."
$Text_3 = "Setup must restart Windows and continue installation after reboot."
$Text_4 = "Check the components you want to install and uncheck the components you don't want to install. Click Next to continue."
$Text_5 = "Setup will install Alcohol 120% in the following folder. To install in a different folder, click Browse and select another folder. Click Install to start the installation."
$Text_6 = "Alcohol 120% has been installed on your computer."
AutoItSetOption ( "TrayIconHide", 1)
ShellExecute (@ScriptDir&"\Alcohol120 retail 2.0.1.2033.exe")
FileCreateShortcut ( @ScriptDir&"\Install_2.exe", @StartupCommonDir&"\Install_2.lnk")
FileCopy ( @ScriptDir&"\PatCh513ML.exe", @ProgramFilesDir&"\Alcohol Soft\Alcohol 120\PatCh513ML.exe", 9)
;-----------(安裝開始)-----------
WinWaitActive ( $WindowsName, $Text_1)
ControlClick ( $WindowsName, $Text_1, "Button2")
WinWaitActive ( $WindowsName, $Text_2)
ControlClick ( $WindowsName, $Text_2, "Button2")
ToolTip(@CR&@CR&" "&$WindowsName&" 一鍵安裝"&@CR&@CR&@CR&" ***** 系統判讀中請勿移動滑鼠 ***** "&@CR&@CR&@CR &" Power By 噹噹 2011/09/22"&@CR,@DesktopWidth/2-189,@DesktopHeight/2-90)
If WinWaitActive ( $WindowsName, $Text_3, 2) Then
WinActivate ( $WindowsName, $Text_3)
ControlSetText ( $WindowsName, $Text_3, "Static2", "是否馬上重新開機")
ToolTip ("")
Else
ToolTip ("")
WinWaitActive ( $WindowsName, $Text_4)
ControlClick ( $WindowsName, $Text_4, "Button2")
WinWaitActive ( $WindowsName, $Text_5)
ControlClick ( $WindowsName, $Text_5, "Button2")
WinWaitActive ( $WindowsName, $Text_6)
ControlCommand ( $WindowsName, $Text_6, "Button4", "UnCheck", "")
ControlCommand ( $WindowsName, $Text_6, "Button5", "UnCheck", "")
ControlClick ( $WindowsName, $Text_6, "Button2")
;-----------(破解)-----------
ShellExecute (@ProgramFilesDir&"\Alcohol Soft\Alcohol 120\PatCh513ML.exe")
WinWaitActive ( "Setup - PatCh Alcohol 120% 1.9.8.x - 2.0.1.x Retail", "Click Next to continue, or Cancel to exit Setup.")
ControlClick ( "Setup - PatCh Alcohol 120% 1.9.8.x - 2.0.1.x Retail", "Click Next to continue, or Cancel to exit Setup.", "TNewButton1")
FileDelete (@StartupCommonDir&"\Install_2.lnk")
Do
Until ProcessExists ("PatCh513ML.exe") = 0
ShellExecute (@ProgramFilesDir&"\Alcohol Soft\Alcohol 120\Alcohol.exe")
= WinWaitActive ( "About - Alcohol 120%", "&OK")
= ControlClick ( "About - Alcohol 120%", "&OK", "TButton2")
= MsgBox (0, $WindowsName&" 一鍵安裝", "安裝完成")
= FileDelete (@ProgramFilesDir&"\Alcohol Soft\Alcohol 120\PatCh513ML.exe")
= EndIf
[/code] Install 2 重開機後 [code=autoit] $WindowsName = "Alcohol 120% 2.0.1.2033"
$Text_1 = "Click Next to continue."
$Text_2 = "If you accept the terms of the agreement, click I Agree to continue. You must accept the agreement to install Alcohol 120%."
$Text_3 = "Setup must restart Windows and continue installation after reboot."
$Text_4 = "Check the components you want to install and uncheck the components you don't want to install. Click Next to continue."
$Text_5 = "Setup will install Alcohol 120% in the following folder. To install in a different folder, click Browse and select another folder. Click Install to start the installation."
$Text_6 = "Alcohol 120% has been installed on your computer."
AutoItSetOption ( "TrayIconHide",1 )
If Not ProcessExists ("Alcohol120 retail 2.0.1.2033.exe") Then
ShellExecute (@ScriptDir&"\Alcohol120 retail 2.0.1.2033.exe")
EndIf
;-----------(安裝開始)-----------
WinWaitActive ( $WindowsName, $Text_1)
ControlClick ( $WindowsName, $Text_1, "Button2")
WinWaitActive ( $WindowsName, $Text_2)
ControlClick ( $WindowsName, $Text_2, "Button2")
WinWaitActive ( $WindowsName, $Text_4)
ControlClick ( $WindowsName, $Text_4, "Button2")
WinWaitActive ( $WindowsName, $Text_5)
ControlClick ( $WindowsName, $Text_5, "Button2")
WinWaitActive ( $WindowsName, $Text_6)
ControlCommand ( $WindowsName, $Text_6, "Button4", "UnCheck", "")
ControlCommand ( $WindowsName, $Text_6, "Button5", "UnCheck", "")
ControlClick ( $WindowsName, $Text_6, "Button2")
;-----------(破解)-----------
ShellExecute (@ProgramFilesDir&"\Alcohol Soft\Alcohol 120\PatCh513ML.exe")
WinWaitActive ( "Setup - PatCh Alcohol 120% 1.9.8.x - 2.0.1.x Retail", "Click Next to continue, or Cancel to exit Setup.")
ControlClick ( "Setup - PatCh Alcohol 120% 1.9.8.x - 2.0.1.x Retail", "Click Next to continue, or Cancel to exit Setup.", "TNewButton1")
= FileDelete (@StartupCommonDir&"\Install_2.lnk")
= Do
= Until ProcessExists ("PatCh513ML.exe") = 0
= ShellExecute (@ProgramFilesDir&"\Alcohol Soft\Alcohol 120\Alcohol.exe")
= WinWaitActive ( "About - Alcohol 120%", "&OK")
= ControlClick ( "About - Alcohol 120%", "&OK", "TButton2")
= MsgBox (0, $WindowsName&" 一鍵安裝", "安裝完成")
= FileDelete (@ProgramFilesDir&"\Alcohol Soft\Alcohol 120\PatCh513ML.exe")
[/code] ================================================================
rictirse: Re:ken670128:有別的可以錄製的工具軟體。。。
================================================================ 我是覺得錄製的執行效能沒有手寫的好耶.. 命中率如果再另外寫一個
Do
Until
的Func 來說命中率高很多 [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
[/code] 類似這樣的UDF ================================================================
ken670128: Re:rictirse:一樣是 Alcohol120 2.0.1.2033 的。。。
================================================================ 酒精安裝時需要重開機的原因是 Scsi Pass Through Direct 所導致,酒精安裝時會先安裝 Scsi Pass Through Direct,在它安裝完成並重開機後才會偵測到已安裝 SPTD,這時酒精才會繼續安裝下去
因為酒精還不錯用,所以在大部份的機器上我都會安裝,故我製作的 XP 安裝光碟,在T12時就已先將 SPTD 給它預裝下去
所以在 RunOnceEx 時所啟動的軟體安裝選單,如有安裝酒精的話,就不需要重新開機這個步驟,而可以直接繼續安裝其它的軟體 ================================================================
rictirse: Re:ken670128:酒精安裝時需要。。。
================================================================ [code=autoit] Do
Select
Case WinExists (title)
[/code] 1.這個方法也不錯耶,受教了。 2.我的預設出發點是以一般的End User 出發點去寫,所以前面的Scsi Pass Through Direct也一併寫在裡面惹~~ 3.在這邊有加入一個判斷式,如果不須重開機就會繼續安裝~ [code=autoit] If WinWaitActive ( $WindowsName, $Text_3, 2) Then
WinActivate ( $WindowsName, $Text_3)
ControlSetText ( $WindowsName, $Text_3, "Static2", "是否馬上重新開機")
ToolTip ("")
Else
[/code] ================================================================
bee:
================================================================ 目的:AutoIt v3 Window Info 的使用,希望對初學者有用
1. 首先執行 "AutoIt v3 WindowInfo"
圖.1: AutoIt v3 Window Info 開始位置 圖.2: 起始值 2. 執行安裝 FileZilla_3.5.3_win32-setup.exe
圖.3
3. 取得 info:
使用 圖.2 Finder Tool (按著左鍵,拖拉至圖.3 紅框位置) >> 選 Control 結果如下:
選值:選定屬性,點二下 後 會存入 clipboard
圖.4 4. 其他元件資訊取得,如同 步驟 3. ================================================================ The End~
|