|
1安装前会判断安装程序是否存在, 延时5秒自动退出
2.安装前有用户确认的消息框,延时5秒按确认处理
$sAppName = "“鲁大师”"
$sInstallerName = "Ludashi_Setup.exe"
$sMsgBox_Title = "自动安装"
; 此段脚本判断安装文件是否存在,如果不存在显示提示消息框后退出
$sCannotFindInstaller = "安装终止:无法找到安装程序 "
if Not FileExists($sInstallerName) Then
$MsgBox_Text = $sCannotFindInstaller & @ScriptDir &"\"& $sInstallerName
MsgBox(270352, $sMsgBox_Title , $MsgBox_Text, 5)
Exit
EndIf
; 此段脚本显示确认继续安装消息框,消息框按钮为是和否
$sSureContinue = "将被安装到D盘,要继续吗?"
$sWarnning = "警告:安装前请先退出所有正在运行的 Windows 应用程序。"
$MsgBox_Text = $sAppName & $sSureContinue & @CRLF & @CRLF & $sWarnning
; 选择“否”则退出,否则继续执行脚本
if (MsgBox(270372, $sMsgBox_Title, $MsgBox_Text,5) = 7) Then
; 退出
Exit
Else
; 执行安装程序
Run($sInstallerName)
EndIf
; 显示托盘区提示
$sSetupNow = "正在安装"
$sTrayTip_Text = $sSetupNow & $sAppName
$sTrayTipIcon = 1 ; 0=没有图标(默认), 1=消息, 2=警告, 3=错误
TrayTip($sMsgBox_Title, $sTrayTip_Text, 10, $sTrayTipIcon)
$Title = "安装 - 鲁大师"
$Title1 = "文件夹存在"
$Comment1 = "欢迎使用 鲁大师 安装向导"
$Comment2 = "许可协议"
$Comment3 = "选择目标位置"
$Comment4 = "选择附加任务"
$Comment5 = "正在安装"
$Comment6 = "鲁大师 安装向导完成"
$Comment7 = "360安全浏览器"
; 欢迎 界面
WinWait($Title, $Comment1)
if Not WinActive($Title, $Comment1) then WinActivate($Title, $Comment1)
WinWaitActive($Title, $Comment1)
; 点击 “下一步” 按钮,快捷键Alt+N
Send("!n")
; 许可协议 界面
WinWait($Title, $Comment2)
if Not WinActive($Title, $Comment2) then WinActivate($Title, $Comment2)
WinWaitActive($Title, $Comment2)
;点击“我同意(&A)”按钮,快捷键为Alt+A
Send("!a")
; 点击 “下一步” 按钮,快捷键Alt+N
Send("!n")
; 选择目标位置 界面
WinWait($Title, $Comment3)
if Not WinActive($Title, $Comment3) then WinActivate($Title, $Comment3)
WinWaitActive($Title, $Comment3)
; 路径输入框聚焦
ControlFocus ($Title, $Comment3, "Edit1")
; 修改安装目录为 D盘
Send("{Home}{Delete}D")
; 点击 “下一步” 按钮,快捷键Alt+N
Send("!n")
; 文件夹存在
WinWait($Title1, "")
if Not WinActive($Title1, "") then WinActivate($Title1, "")
WinWaitActive($Title1, "")
; 点击 “是(&Y) 按钮,快捷键Alt+Y
Send("!y")
; 选择附加任务 界面
WinWait($Title, $Comment4)
if Not WinActive($Title, $Comment4) then WinActivate($Title, $Comment4)
WinWaitActive($Title, $Comment4)
; 勾选选项 “创建桌面快捷方式” ,快捷键Alt+D
; 该选项为默认选定选项
;Send("!d")
; 点击 “下一步” 按钮开始安装,快捷键Alt+N
Send("!n")
; 正在安装 界面
WinWait($Title, $Comment5)
if Not WinActive($Title, $Comment5) then WinActivate($Title, $Comment5)
WinWaitActive($Title, $Comment5)
; 灰化 “取消” 按钮
;ControlDisable ($Title, $Comment5, "Button1")
; 鲁大师 安装向导完成
WinWait($Title, $Comment6)
if Not WinActive($Title, $Comment6) then WinActivate($Title, $Comment6)
WinWaitActive($Title, $Comment6)
; 去掉勾选选项 “运行 鲁大师”
;if ControlCommand ($Title, $Comment6, "Button1", "IsChecked", "") Then
; ControlCommand ($Title, $Comment6, "Button1","UnCheck", "")
;EndIf
Send("{Space}")
; 点击 “完成(&F)” 按钮,快捷键Alt+F
Send("!F")
; 鲁大师推荐-装机必备 360安全浏览器
WinWait($Title, $Comment7, 3)
if WinExists($Title, $Comment7) Then
if Not WinActive($Title, $Comment7) then WinActivate($Title, $Comment7)
WinWaitActive($Title, $Comment7)
; 去掉勾选选项 “运行 鲁大师”
if ControlCommand ($Title, $Comment7, "TCheckBox1", "IsChecked", "") Then
ControlCommand ($Title, $Comment7, "TCheckBox1","UnCheck", "")
EndIf
EndIf
; 点击 “确定” 按钮,无快捷键
Send("{Enter}")
; 退出
Exit |
|