|
本帖最后由 ziyaxian 于 2009-5-7 16:36 编辑
我想3秒钟对所有服务器PING一次看其是否中断,但是用while以后,关不了这个程序了,请高手指点一下:代码如下:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <date.au3>
Opt("TrayMenuMode", 1)
$g_szVersion = "服务器网络监控"
If WinExists($g_szVersion) Then Exit ; 此脚本已经运行了
AutoItWinSetTitle($g_szVersion)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("服务器网络监控", 265, 394, -1, -1)
_ping()
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _ping()
While 1
Local $var,$a,$s
$b=8
$var = IniReadSection("config.ini", "名称")
If @error <> 1 Then
For $i = 1 to $var[0][0]
$a = ping ( $var[$i][0],1000 )
If $a Then
$s =$var[$i][1]
$Input1 = GUICtrlCreateInput($s, 8, $b, 105, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$Input2 = GUICtrlCreateInput("正常", 123, $b, 61, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$Input3 = GUICtrlCreateInput("延时:"&$a, 191, $b, 65, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
Else
$s =$var[$i][1]
$Input1 = GUICtrlCreateInput($s, 8, $b, 105, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$Input2 = GUICtrlCreateInput("网络中断", 123, $b, 61, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlSetColor(-1, 0xff0000)
$Input3 = GUICtrlCreateInput("请速处理", 191, $b, 65, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlSetColor(-1, 0xff0000)
EndIf
$b=$b+25
Next
EndIf
$Input25 = GUICtrlCreateInput("日期/时间:" & _now(), 21, 363, 221, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUISetState(@SW_SHOW)
Sleep(3000)
WEnd
EndFunc |
|