|
本帖最后由 zzfbz 于 2009-5-19 20:16 编辑
初学者,也曾写过几十个自动安装脚本,今天写Nero,花了一天的时间,遇到几个难点:读起注册机序列号、循环语句的使用、修改控件以写入安装路径、如何选择TreeView32控件中的安装选项、鼠标的定位等。不管脚本的通用程度或使用频率如何,但通过脚本的编写,学了不少东西,这才是主要的。
Nero:9.2.6.0版,注册机:keymaker4.0版,两台不同分辨率的电脑上安装通过.
安装路径:D:\Program Files\Nero
安装组件:Nero Burning ROM
Nero StartSmart
Nero CoverDesigner
Nero Express
征求意见:本脚本中的循环语句不知道是否正确,TreeView32控件中的选择安装选项或组件问题,鼠标定位问题。如果大家对Nero的自动安装没什么兴趣的话,也请单纯就脚本的编写和上述问题提点意见和建议。谢谢!
run(@ScriptDir&'\nero.exe',@ScriptDir)
traytip("nero","正在自动安装NERO",5)
$hd1="Nero 9 Trial - 安装"
$hd2="Nero 9 HD - 安装"
$hd3="Nero 9.0 Keygen"
$wb1="Re-Detect nero"
WinWaitActive($hd1,"欢迎使用 Nero 9 Trial 安装向导")
Send("!n")
WinWaitActive($hd1,"安装 Nero Ask Toolbar")
Send("!s")
Send("!n")
sleep(3000)
run(@ScriptDir&'\keymaker.exe',@ScriptDir)
WinWaitActive($hd3,$wb1)
ControlClick($hd3,$wb1,"TButton8")
sleep(2000)
ControlClick($hd3,$wb1,"TButton7")
sleep(2000)
ControlGetText($hd3,$wb1,"TEdit1")
sleep(2000)
WinActivate($hd1,"序列号")
WinWaitActive($hd1,"")
ControlSetText($hd1,"","Edit1",ControlGetText($hd3,$wb1,"TEdit1"))
sleep(3000)
Send("!n")
sleep(2000)
For $i = 1 to 20
sleep(500)
if WinExists($hd2,"协议生效")=1 then exitloop
WinWaitActive($hd3,$wb1)
ControlClick($hd3,$wb1,"TButton8")
sleep(2000)
ControlClick($hd3,$wb1,"TButton7")
sleep(2000)
ControlGetText($hd3,$wb1,"TEdit1")
sleep(2000)
WinActivate($hd2,"请输入您的 Nero 9 HD 序列号")
WinWaitActive($hd2,"")
ControlSetText($hd2,"","Edit1",ControlGetText($hd3,$wb1,"TEdit1"))
sleep(3000)
Send("!n")
sleep(2000)
next
WinClose($hd3,$wb1)
WinActivate($hd2,"我接受许可证条款")
WinWaitActive($hd2,"我接受许可证条款")
ControlClick($hd2,"","Button6")
Send("!n")
WinWaitActive($hd2,"请选择安装类型")
ControlClick($hd2,"","Button6")
Send("!n")
WinWaitActive($hd2,"选择安装 Nero 9 HD 的文件夹")
winmove($hd2,"选择安装 Nero 9 HD 的文件夹",0,0)
opt("MouseCoordMode",0)
sleep(500)
ControlEnable($hd2,"","Edit1")
ControlSetText($hd2,"","Edit1","D:\Program Files\Nero")
MouseClick ("right",80,222)
MouseClick ("left",80,287)
MouseClick ("right",80,238)
MouseClick ("left",80,298)
MouseClick ("right",80,254)
MouseClick ("left",80,316)
MouseClick ("left",80,270)
MouseClick ("left",80,332)
MouseClick ("left",80,286)
MouseClick ("left",80,345)
MouseClick ("left",80,318)
MouseClick ("left",80,381)
MouseClick ("left",80,334)
MouseClick ("left",80,396)
MouseClick ("left",80,350)
MouseClick ("left",80,414)
MouseClick ("left",80,366)
MouseClick ("left",80,431)
MouseClick ("left",377,370,8)
MouseClick ("right",80,254)
MouseClick ("left",80,316)
MouseClick ("left",80,270)
MouseClick ("left",80,332)
MouseClick ("left",80,318)
MouseClick ("left",80,381)
MouseClick ("left",80,334)
MouseClick ("left",80,396)
MouseClick ("left",377,370,6)
MouseClick ("left",80,270)
MouseClick ("left",80,332)
MouseClick ("left",80,350)
MouseClick ("left",80,414)
MouseClick ("left",80,366)
MouseClick ("left",80,431)
Send("!n")
WinWaitActive($hd2,"选择应用程序语言")
Send("!n")
WinWaitActive($hd2,"参与收集此匿名信息")
Send("!n")
WinWaitActive($hd2,"退出")
Send("!e") |
|