tianya1631 发表于 2010-3-1 22:07:46

ping通IP就关闭某个程序问题?

帮我看看这个问题,现在是这样的问题,如果ping不通的话,可以自动打开迅雷,但是特别卡,按stop停止不了,估计是循环有问题,帮我看看。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Ping Close", 357, 196, -1, -1)
GUISetIcon("D:\009.ico")
$GroupBox1 = GUICtrlCreateGroup("Ping", 8, 8, 257, 73)
$Label1 = GUICtrlCreateLabel("IP :", 40, 36, 28, 17)
$InputIP = GUICtrlCreateInput("", 78, 32, 137, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Start = GUICtrlCreateButton("Start(&S)", 272, 40, 75, 25, 0)
$stop = GUICtrlCreateButton("Stop(&C)", 272, 88, 75, 25, 0)
$state = GUICtrlCreateInput("", 8, 88, 257, 80, $WS_DISABLED)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1

        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ExitLoop
                Case $Start

                        GUICtrlSetState($InputIP, $GUI_DISABLE)
                        GUICtrlSetState($Start, $GUI_DISABLE)
                        AdlibRegister("pin")
                Case $stop
                        GUICtrlSetState($stop, $GUI_DISABLE)
                        GUICtrlSetState($InputIP, $GUI_ENABLE)
                        GUICtrlSetState($Start, $GUI_ENABLE)
                        AdlibUnRegister("pin")
                        GUICtrlSetState($stop, $GUI_ENABLE)
        EndSwitch
WEnd

Func Pin()
        Local $ip, $pid
    $IP = GUICtrlRead ($InputIP)
        $pid = ProcessExists("thunder.exe")
        $pin = Ping($IP)
       
        If $pinThen
                If $pid Then
                ProcessClose($pid)
                GUICtrlSetData($state, "通信正常,迅雷关闭")
                EndIf
        Else
                If Not ProcessExists("thunder.exe") Then
                Run("D:\Program Files\Thunder Network\Thunder\Program\Thunder.exe")
                GUICtrlSetData($state, "通信失败,迅雷工作")
                EndIf       
        EndIf

EndFunc   ;==>Pin

tianya1631 发表于 2010-3-1 23:56:08

囧,,太简单了,没人愿意回答啊。。。。楼下的回答下。。
页: [1]
查看完整版本: ping通IP就关闭某个程序问题?