;--------------------------------------------------------------;脚本开始
Opt("TrayIconDebug", 1) ;0=无信息, 1=调试信息 ;托盘代码提示
Opt("WinTextMatchMode", 2) ;1=完全匹配, 2=快速匹配 ;文字匹配方式
Opt("WinTitleMatchMode", 4) ;1=开头, 2=子串, 3=完全, 4=高级 ;标题匹配方式
Opt("WinSearchChildren", 1) ;0=不搜索, 1=搜索子窗口 ;检测子窗口
Opt("WinDetectHiddenText", 1) ;0=不检测, 1=检测 ;检测隐藏文字
;--------------------------------------------------------------;设置脚本参数
Opt("MouseCoordMode", 0) ;相对激活窗口的坐标
Dim $WinTitle_1= "迅雷7安装程序"
Dim $WinTitle_2= "迅雷7"
Dim $Wintxt_1= "软件许可协议"
Dim $Wintxt_2= ""
Dim $Wintxt_3= "C:\Program Files\Thunder Network\Thunder"
;--------------------------------------------------------------;窗口元素变量声明
TrayTip ( "温馨提示", "正在自动安装请不要动鼠标键盘"&@CRLF&"反馈http://www.joz7.com",5,4)
;--------------------------------------------------------------;右下角气泡提示
$Exe = 'Thunder7_Setup.exe'
If ProcessExists($Exe) Then ProcessClose($Exe)
If Run($Exe) = 0 Then ShellExecute($Exe)
Do
Sleep(10);
Until WinExists($Wintitle_1)
;WinMove($Wintitle_1, "", -1000, -1000)
;--------------------------------------------------------------;程序启动,显示界面
WinWaitActive($WinTitle_1, $Wintxt_1)
ControlClick($WinTitle_1, $Wintxt_1, "Button1")
WinWaitActive($WinTitle_1, $Wintxt_3)
ControlClick($WinTitle_1, $Wintxt_3, "Button5")
ControlClick($WinTitle_1, $Wintxt_3, "Button9")
ControlClick($WinTitle_1, $Wintxt_3, "Button7")
;Sleep(500)
WinWaitActive($WinTitle_2, $Wintxt_2)
ControlClick($WinTitle_2, $Wintxt_2, "Button2")
WinWaitActive($WinTitle_1, $Wintxt_3)
ControlClick($WinTitle_1, $Wintxt_3, "Button1")
;Sleep(500)
WinWaitActive($WinTitle_2, $Wintxt_2)
ControlClick($WinTitle_2, $Wintxt_2, "Button2") ;以上都是等待并激活窗口,因为窗口信息工具无法抓取文本
WinWaitActive($WinTitle_1, $Wintxt_2) ;这个就是难点,因为有两个窗口没有文本,但有一个是带有button的
While 1
If ControlGetHandle($WinTitle_1,$Wintxt_2,"Button4") Then ExitLoop ;这里是在等有button4的窗口
;等到后向下执行
Sleep(200)
WEnd
ControlClick($WinTitle_1, $Wintxt_2, "Button4")
ControlClick($WinTitle_1, $Wintxt_2, "Button5")
ControlClick($WinTitle_1, $Wintxt_2, "Button7")
ControlClick($WinTitle_1, $Wintxt_2, "Button1")
FileDelete ("C:\Documents and Settings"&@UserName&"\Application Data\Microsoft\Internet Explorer\Quick Launch\迅雷7.lnk") ;--------删除文件--------
;--------------------------------------------------------------;删除多余图标
;FileCopy ( "config.ini", "C:\Program Files\Thunder Network\Thunder\Profiles\config.ini",1)
;--------------------------------------------------------------;config.ini为迅雷配置文件
部分代码参考 谢谢