#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$ccc=0
$111=-1
$aaa=0
$Form1 = GUICreate("Form1", 458, 360, 435, 318)
$ListView1 = GUICtrlCreateListView("服务器昵称 |IP/域名 |状态 |丢包情况 ", 8, 24, 440, 289)
_GUICtrlListView_SetExtendedListViewStyle($ListView1 , BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
$var = IniReadSection("Ip.ini", "服务器")
If @error Then
MsgBox(4096, "", "发生错误,可能目标文件并非标准的INI文件.")
Else
For $i = 1 To $var[0][0]
GUICtrlCreateListViewItem($var[$i][0] & "|" & $var[$i][1] & "|待测 |待测" , $ListView1)
Next
EndIf
$Button2 = GUICtrlCreateButton("停止检测", 375, 320, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "宋体")
GUICtrlSetOnEvent(-1, "sotp")
$Button1 = GUICtrlCreateButton("开始检测", 288, 320, 75, 25)
GUICtrlSetOnEvent(-1, "pingla")
GUICtrlSetFont(-1, 9, 400, 0, "宋体")
$Checkbox1 = GUICtrlCreateCheckbox("日志记录", 210, 325, 65, 17)
GUICtrlSetFont(-1, 9, 400, 0, "宋体")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep (150)
WEnd
Func sotp()
RegWrite("HKEY_CURRENT_USER\Software\ping","ping",'Reg_sz',"yes")
$ccc=10
EndFunc
Func pingla()
While $ccc<>10
$111=-1
$ok=RegRead("HKEY_CURRENT_USER\Software\ping","ping")
if $ok="yes"Then
$ccc=10
RegDelete("HKEY_CURRENT_USER\Software\ping","ping")
ExitLoop
EndIf
$var = IniReadSection("Ip.ini", "服务器")
If @error Then
MsgBox(4096, "", "发生错误,可能目标文件并非标准的INI文件.")
Else
For $i = 1 To $var[0][0]
$aaa=0
$111=$111+1
$1 = Ping($var[$i][1],250)
if @error Then
$aaa=$aaa+1
_GUICtrlListView_AddSubItem($ListView1, $111, "第一次失败", 2)
_GUICtrlListView_AddSubItem($ListView1, $111, $aaa*25&" %", 3)
EndIf
$2 = Ping($var[$i][1],250)
if @error Then
$aaa=$aaa+1
_GUICtrlListView_AddSubItem($ListView1, $111, "第二次失败", 2)
_GUICtrlListView_AddSubItem($ListView1, $111, $aaa*25&" %", 3)
EndIf
$3 = Ping($var[$i][1],250)
if @error Then
$aaa=$aaa+1
_GUICtrlListView_AddSubItem($ListView1, $111, "第三次失败", 2)
_GUICtrlListView_AddSubItem($ListView1, $111, $aaa*25&" %", 3)
EndIf
$4 = Ping($var[$i][1],250)
if @error Then
$aaa=$aaa+1
_GUICtrlListView_AddSubItem($ListView1, $111, "第四次失败", 2)
_GUICtrlListView_AddSubItem($ListView1, $111, $aaa*25&" %", 3)
EndIf
$cc=($1+$2+$3+$4)/4
if $cc=0 Then
$cc="ping不通"
EndIf
if $cc=0 Then
_GUICtrlListView_AddSubItem($ListView1, $111, $cc, 2)
Else
_GUICtrlListView_AddSubItem($ListView1, $111, $cc&" MS", 2)
EndIf
_GUICtrlListView_AddSubItem($ListView1, $111, $aaa*25&" %", 3)
Sleep(200)
Next
EndIf
WEnd
EndFunc
Func CLOSEClicked()
MsgBox(0, "GUI 事件", "您选择了关闭!正在退出...")
Exit
EndFunc
我试了是可以的,怎么你就不行呢?郁闷ing...
[ 本帖最后由 xkowen 于 2008-12-2 14:34 编辑 ] |