在GUI里循环PING如何实现(已解决)
本帖最后由 xzh531 于 2017-1-10 08:44 编辑我要实现如下功能,就是经验少,不知道怎么处理,求大神给分享几个方法,谢谢
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 307, 182, -1, -1)
$Label1 = GUICtrlCreateLabel("延时 MS", 80, 20, 56, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$button1 = GUICtrlCreateButton("开始", 20, 100, 50, 25)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$button2 = GUICtrlCreateButton("停止", 100, 100, 50, 25)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1 ;开始循环PING
chk()
Case $button2 ;停止PING
EndSwitch
WEnd
Func chk()
While 1
$p = Ping("192.168.6.1", 400)
If Not @error Then
GUICtrlSetState($Label1, "延时 " & $p & "MS")
EndIf
Sleep(3000)
WEnd
EndFunc ;==>chk 本帖最后由 q410225 于 2017-1-7 11:47 编辑
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 307, 182, -1, -1)
$Label1 = GUICtrlCreateLabel("延时 MS", 80, 20, 56, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$button1 = GUICtrlCreateButton("开始", 20, 100, 50, 25)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$button2 = GUICtrlCreateButton("停止", 100, 100, 50, 25)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1 ;开始循环PING
AdlibRegister(chk,2000)
Case $button2 ;停止PING
AdlibUnRegister(chk)
GUICtrlSetData($Label1, "延时---MS")
EndSwitch
WEnd
Func chk()
GUICtrlSetData($Label1, "延时---MS")
Sleep(500)
$p = Ping("192.168.6.1", 400)
If $p Then
GUICtrlSetData($Label1, "延时"&$p&"MS")
EndIf
EndFunc ;==>chk
本帖最后由 xzf680 于 2017-1-8 11:30 编辑
{:face (280):} 学习下
页:
[1]