大虾,看完你的东西后自己参悟了一下,但是还是不行啊!刚执行到_coproc("upgrade")的地方程序就完全退出了!感觉明显有错,又不知道错在什么地方,麻烦大虾帮忙看看,谢谢!
代码如下:(这段代码中test()是循环的!)
\#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\Program Files\AutoIT3\Aut2Exe\Icons\kde.ico
#AutoIt3Wrapper_outfile=E:\Soft\Myexe\DVS_Reboot_V0.1\DVS_Upgrade.exe
#AutoIt3Wrapper_Res_Comment=目前不支持重启!
#AutoIt3Wrapper_Res_Description=DVS Auto Upgrade
#AutoIt3Wrapper_Res_Fileversion=0.1.0.0
#AutoIt3Wrapper_Res_LegalCopyright=OWEN
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <IE.au3>
#Include <date.au3>
#include <GUIConstants.au3>
#include <coproc.au3>
$IPaddr=IniRead("video.ini","video","IPaddr","192.168.200.110")
$User=IniRead("video.ini","video","User","admin")
$PWD=IniRead("video.ini","video","Password","admin")
$Loop=iniread("video.ini","video","Loop","1000")
$Sleep=iniread("video.ini","video","Sleep","60")
$Type=iniread("video.ini","video","Type","GrandStream")
$PageID_1=IniRead("video.ini","video","PageID","Pages/maintenance.asp")
$Delay=IniRead("video.ini","video","Delay","30")
$IP=$IPaddr&"/"&$PageID_1
$Title="连接到 " & $IPaddr
Dim $i0=0
$Downgrade=IniRead("video.ini","video","Downgrade","")
$Upgrade=IniRead("video.ini","video","Upgrade","")
$Upgrade_version=IniRead("video.ini","upload","Upgrade_version","")
$Downgrade_version=IniRead("video.ini","upload","Downgrade_version","")
;====>version
Opt("GUIOnEventMode", 1)
$window=GUICreate("DVS TEST",250, 120, 407, 452)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$Group1 = GUICtrlCreateGroup("请稍等(20s)...", 8, 8, 233, 103)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("IP:", 16, 32, 17, 17)
$Label2 = GUICtrlCreateLabel("统计:", 16, 50, 31, 17)
$Label3 = GUICtrlCreateLabel("开始:", 16, 68, 31, 17)
$Label4 = GUICtrlCreateLabel("结束:", 16, 86, 31, 17)
$Label5 = GUICtrlCreateLabel($IPaddr, 48, 32, 190, 17)
$Label6 = GUICtrlCreateLabel("0 (successful!)", 48, 50, 190, 17)
$Label7 = GUICtrlCreateLabel("00年/00月/00日 00时/00分/00秒", 48, 68, 190, 17)
$Label8 = GUICtrlCreateLabel("00年/00月/00日 00时/00分/00秒", 48, 86, 190, 17)
$Label9 = GUICtrlCreateLabel("Grandstream Networks,Inc.2008", 38, 103, 185, 12)
GUICtrlSetColor(-1, 0x808080)
GUICtrlCreateGroup("", -99, -99, 1, 1)
autoitsetoption("TrayAutoPause",0)
GUISetState(@SW_SHOW)
GUICtrlSetData($Label5,$IPaddr&" Up/Downgrade")
Sleep(15000)
$PID=_coproc("upgrade")
$ping=ping($IPaddr,5)
If $ping Then
$start_time=_NowCalc()
GUICtrlSetData($Label7,$start_time)
Else
GUICtrlSetData($Group1,"Disconnected...")
MsgBox(0,"Error msg!","无法连接到目标IP,请确认网络连接良好!")
Exit
EndIf
While 1
test()
WEnd
Func test()
$IE=_IECreate($IP,0,0,0,0)
WinWait($Title,$Type,30)
$msg1=WinExists($Title,$Type)
If $msg1=0 Then
sleep(100)
Else
controlsend($Title,$Type,"Edit2","admin",0)
controlsend($Title,$Type,"Edit3","admin",0)
ControlClick($Title,$Type,"Button1")
ControlClick($Title,$Type,"Button2")
sleep(1500)
;===>有界面,登录并记住密码!
EndIf
$button=_IEGetObjByName($IE,"Upgrade")
$IE2=_iecreate($IPaddr&"/Pages/about.asp",0,0,1,0)
$get_txt=_IEBodyReadText($IE2)
$check_upgrade=StringRegExp($get_txt,$Upgrade_version,0)
$check_downgrade=StringRegExp($get_txt,$Downgrade_version,0)
_IEQuit($IE2)
_ProcResume($PID);===>恢复子进程
$button2=_IEGetObjByName($IE,"fimage")
_IEAction($button2,"click")
Sleep(2000)
_ProcSuspend($PID);===>暂停子进程
_IEAction($button,"click")
Sleep($Sleep*1000)
EndFunc
Func Upgrade()
$msg=WinExists("选择文件","文件名")
If $msg=1 Then
WinSetTrans("选择文件","文件名",0)
If $check_upgrade=1 Then
ControlSetText("选择文件","文件名","Edit1",$Downgrade)
ElseIf $check_downgrade=1 Then
ControlSetText("选择文件","文件名","Edit1",$Upgrade)
EndIf
Sleep(1000)
ControlClick("选择文件","文件名","Button2","left")
EndIf
EndFunc
Func CLOSEClicked()
$box = MsgBox(1, "关闭?", "你确定要退出DVS TEST程序?")
If $box = 1 Then
Exit
EndIf
EndFunc
[ 本帖最后由 xkowen 于 2008-11-24 22:06 编辑 ] |