自動運行升級程序,輸入所需信息,中間記錄日志文件
參數(shù)1:升級程序膊毁,參數(shù)2:服務(wù)器IP,參數(shù)3:賬號基跑,參數(shù)4:密碼婚温, 參數(shù)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 & "輸入服務(wù)器IP")
WinWait("請輸入服務(wù)器IP地址","",10);等待輸入服務(wù)器IP地址窗口,不用WinWaitActive可能窗口不為激活狀態(tài)
If WinExists("請輸入服務(wù)器IP地址") Then;是否有輸入窗口
? ControlSetText("請輸入服務(wù)器IP地址","127.0.0.1","Edit1",$CMDLine[2]);輸入IP地址
? FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "點擊確定")
? ControlClick("請輸入服務(wù)器IP地址","確定(&K)","Button1");點擊確定
? Sleep(5000)
Else
? FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "未出現(xiàn)輸入IP框")
? Exit -1
EndIf
WinWait("服務(wù)器升級提示","",30);等待服務(wù)器升級提示窗口變成活動
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "等待服務(wù)器升級提示窗口變成活動")
If WinExists("服務(wù)器升級提示") Then;是否有輸入窗口
? FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "服務(wù)器IP不通")
? FileWriteLine($log_file, ControlGetText("服務(wù)器升級提示","","[CLASS:Static; INSTANCE:1]"))
? ControlClick("服務(wù)器升級提示","確定","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("服務(wù)器升級提示-升級失敗","",10);升級失敗提示
If WinExists("服務(wù)器升級提示-升級失敗") Then;服務(wù)器升級提示-升級失敗
? FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "升級失敗")
? FileWriteLine($log_file, ControlGetText("服務(wù)器升級提示-升級失敗","","[CLASS:Static; INSTANCE:1]"))
? ControlClick("服務(wù)器升級提示-升級失敗","","Button1");點擊確定
? Sleep(5000)
? Exit -1
Else
? FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "未找到服務(wù)器升級提示-升級失敗")
EndIf
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "等待升級完成")
$i=1
While $i <= 100
? WinWait("服務(wù)器升級提示","",60);等待服務(wù)器升級提示窗口
? $handle = WinGetHandle("服務(wù)器升級提示")
? WinActivate($handle)
? If WinExists("服務(wù)器升級提示") 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 & "未找到服務(wù)器升級提示")
? EndIf
? $i=$i+1
WEnd
FileWriteLine($temp_file, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "升級失敗")
Exit -1