我想用AU3做一个网络故障预警程序,把需要检测的IP保存在ip.txt中,然后每隔2秒这个程序就会ping一个保存在IP.txt中的IP.并作出是否正常的提示。请各位高手帮看看下面这个程序要怎么改一下。非常感谢。#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("网络故障预警", 357, 196, -1, -1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Start = GUICtrlCreateButton("开始检测(&S)", 272, 40, 75, 25, 0)
$stop = GUICtrlCreateButton("停止检测(&C)", 272, 88, 75, 25, 0)
$state = GUICtrlCreateInput("", 8, 18, 257, 150, $WS_DISABLED)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Start
GUICtrlSetState($Start, $GUI_DISABLE)
AdlibRegister("pin",2000)
Case $stop
GUICtrlSetState($stop, $GUI_DISABLE)
GUICtrlSetState($Start, $GUI_ENABLE)
AdlibUnRegister("pin")
GUICtrlSetState($stop, $GUI_ENABLE)
EndSwitch
WEnd
Func Pin()
$file = FileOpen("ip.txt", 0)
If $file = -1 Then
MsgBox(0, "错误", "不能打开文件.")
Exit
EndIf
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
$pin = Ping($line)
If $pin Then
GUICtrlSetData($state, $line & "工作正常")
Else
GUICtrlSetData($state, $line & "工作不正常")
EndIf
Wend
FileClose($file)
EndFunc ;==>Pin
|