自动运行升级程序,输入所需信息,中间记录日志文件
参数1:升级程序,参数2:服务器IP,参数3:账号,参数4:密码, 参数5:日志文件
au3脚本详情如下:
Local $log_file = FileOpen($CMDLine[5],1);追加写
Local $temp_file = FileOpen("update.log",2);覆盖写
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "运行软件")
run($CMDLine[1])
Sleep(5000)
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "输入服务器IP")
WinWait("请输入服务器IP地址","",10);等待输入服务器IP地址窗口,不用WinWaitActive可能窗口不为激活状态
If WinExists("请输入服务器IP地址") Then;是否有输入窗口
ControlSetText("请输入服务器IP地址","127.0.0.1","Edit1",$CMDLine[2]);输入IP地址
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "点击确定")
ControlClick("请输入服务器IP地址","确定(&K)","Button1");点击确定
Sleep(5000)
Else
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "未出现输入IP框")
Exit -1
EndIf
WinWait("服务器升级提示","",30);等待服务器升级提示窗口变成活动
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "等待服务器升级提示窗口变成活动")
If WinExists("服务器升级提示") Then;是否有输入窗口
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "服务器IP不通")
FileWriteLine($log_file, ControlGetText("服务器升级提示","","[CLASS:Static; INSTANCE:1]"))
ControlClick("服务器升级提示","确定","Button1");点击确定
Sleep(5000)
Exit -1
EndIf
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "等待输入账号密码")
WinWait("请输入web登陆帐号和密码","",10);等待请输入web登陆帐号和密码窗口变成活动
If WinExists("请输入web登陆帐号和密码") Then;是否有输入窗口
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "输入账号密码")
ControlSetText("请输入web登陆帐号和密码","","Edit1",$CMDLine[3]);输入账号
ControlSetText("请输入web登陆帐号和密码","","Edit2",$CMDLine[4]);输入密码
ControlClick("请输入web登陆帐号和密码","确定(&K)","Button1");点击确定
Sleep(5000)
Else
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "不用输入账号密码")
EndIf
WinWait("请输入web登陆帐号和密码","",10);等待请输入web登陆帐号和密码窗口变成活动
If WinExists("请输入web登陆帐号和密码") Then;是否有输入窗口
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "账号密码错误")
Else
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "账号密码正确")
EndIf
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "等待失败提示")
WinWait("服务器升级提示-升级失败","",10);升级失败提示
If WinExists("服务器升级提示-升级失败") Then;服务器升级提示-升级失败
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "升级失败")
FileWriteLine($log_file, ControlGetText("服务器升级提示-升级失败","","[CLASS:Static; INSTANCE:1]"))
ControlClick("服务器升级提示-升级失败","","Button1");点击确定
Sleep(5000)
Exit -1
Else
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "未找到服务器升级提示-升级失败")
EndIf
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "等待升级完成")
$i=1
While $i <= 100
WinWait("服务器升级提示","",60);等待服务器升级提示窗口
$handle = WinGetHandle("服务器升级提示")
WinActivate($handle)
If WinExists("服务器升级提示") Then;等待升级完成
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "升级完成")
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & ControlGetText($handle,"","[CLASS:Static; INSTANCE:1]"))
FileWriteLine($log_file, ControlGetText($handle,"","[CLASS:Static; INSTANCE:1]"))
ControlClick($handle,"","Button1");点击是
ExitLoop
Exit 0
Else
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "未找到服务器升级提示")
EndIf
$i=$i+1
WEnd
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "升级失败")
Exit -1