回复 1# 229989799
麻蛋 搞这没用的东西 浪费我几小时#include <Constants.au3 >
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
ProcessClose("ping.exe")
ProcessClose("ping.exe")
Opt("GUIOnEventMode", 1)
HotKeySet("^c", "Close_Ping")
Global $main = GUICreate("测试窗口", 633, 451, 193, 125)
Global $myedit = GUICtrlCreateEdit("", 5, 32, 620, 200)
Global $Button1 = GUICtrlCreateButton("Ping回显", 8, 408, 617, 33, 0)
;GUISetOnEvent(-3, "gui")
GUICtrlSetOnEvent($Button1, "gui")
GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')
GUISetState(@SW_SHOW)
While 1
Sleep(1)
If GUICtrlGetState($Button1) = 144 Then GUICtrlSetState($Button1, 64)
WEnd
Func gui()
Switch @GUI_CtrlId
Case $Button1
Ping_test()
EndSwitch
EndFunc
Func Ping_test()
GUICtrlSetData($Button1, '正在Ping 再按停止 或按Ctrl+c停止')
;GUICtrlSetState($myedit,128)
Local $foo, $line
$foo = Run('ping -t 127.0.0.1', @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While 1
Local $info = GUIGetCursorInfo($main)
If $info[4] = $Button1 And $info[2] Then
GUICtrlSetData($Button1, 'Ping回显')
If GUICtrlGetState($Button1) = 80 Then GUICtrlSetState($Button1, 128)
Do
$info = GUIGetCursorInfo($main)
Until $info[2] = 0
Return
EndIf
Sleep(99)
$line = StdoutRead($foo)
If @error Then ExitLoop
GUICtrlSetData($myedit, $line, -1)
WEnd
EndFunc
Func Close_Ping()
GUICtrlSetData($Button1, 'Ping回显')
While ProcessExists('ping.exe')
ProcessClose('ping.exe')
WEnd
EndFunc
Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
Switch $wParam
Case 0xF060
Close_Ping()
Exit
EndSwitch
EndFunc
|