找回密码
 加入
搜索
查看: 2190|回复: 1

[网络通信] ping通IP就关闭某个程序问题?

[复制链接]
发表于 2010-3-1 22:07:46 | 显示全部楼层 |阅读模式
帮我看看这个问题,现在是这样的问题,如果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 $pin  Then
                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
 楼主| 发表于 2010-3-1 23:56:08 | 显示全部楼层
囧,,太简单了,没人愿意回答啊。。。。楼下的回答下。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-22 13:51 , Processed in 0.077986 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表