找回密码
 加入
搜索
查看: 1872|回复: 2

使用了定时 但为什么GUI依然会迟钝

[复制链接]
发表于 2009-12-8 04:48:09 | 显示全部楼层 |阅读模式
本帖最后由 karlpopper 于 2009-12-8 04:51 编辑

#NoTrayIcon
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 624, 276, 0, 0)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 345, 233, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Button1 = GUICtrlCreateButton("停止", 488, 160, 113, 33)
$Label1 = GUICtrlCreateLabel("预设超时时间为100ms", 472, 216, 119, 17)
$Label2 = GUICtrlCreateLabel("只显示异常情况", 368, 216, 88, 17)
$Button2 = GUICtrlCreateButton("开始", 376, 160, 105, 33)
$Input1 = GUICtrlCreateInput("192.168.0.254", 440, 32, 153, 21)
$Input2 = GUICtrlCreateInput("www.baidu.com", 440, 96, 153, 21)
$Input3 = GUICtrlCreateInput("59.39.30.0", 440, 64, 153, 21)
$Label3 = GUICtrlCreateLabel("网吧网关", 384, 40, 52, 17)
$Label4 = GUICtrlCreateLabel("电信网关", 384, 72, 52, 17)
$Label5 = GUICtrlCreateLabel("互联网地址", 376, 104, 64, 17)
$data = GUICtrlCreateGroup("设置", 360, 8, 257, 233)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var1="192.168.0.174"
$var2="www.163.cc"
$timeout=100
$Timer = DllCallbackRegister("pingurl", "int","")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
EndSwitch
WEnd

func pingurl()
        $res1=ping($var1,$timeout)
        $res2=ping($var2,$timeout)
        if BitAND($res1,$res2) Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"全部测试成功"&@CRLF," ")
EndIf
        if $res1==0 AND $res1==0 Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"全部测试失败"&@CRLF," ")
EndIf
        if $res1==1 AND $res1==0 Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"内网正常!外网失败!"&@CRLF," ")
EndIf
        if $res1==0 AND $res1==1 Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"外网正常!内网失败!"&@CRLF," ")
EndIf
EndFunc
 楼主| 发表于 2009-12-8 05:21:55 | 显示全部楼层
修改了下 不知道这样可不可以 测试了是还凑合 好点
#NoTrayIcon
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 624, 276, 0, 0)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 345, 233, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Button1 = GUICtrlCreateButton("停止", 488, 160, 113, 33)
$Label1 = GUICtrlCreateLabel("预设超时时间为100ms", 472, 216, 119, 17)
$Label2 = GUICtrlCreateLabel("只显示异常情况", 368, 216, 88, 17)
$Button2 = GUICtrlCreateButton("开始", 376, 160, 105, 33)
$Input1 = GUICtrlCreateInput("192.168.0.254", 440, 32, 153, 21)
$Input2 = GUICtrlCreateInput("www.baidu.com", 440, 96, 153, 21)
$Input3 = GUICtrlCreateInput("59.39.30.0", 440, 64, 153, 21)
$Label3 = GUICtrlCreateLabel("网吧网关", 384, 40, 52, 17)
$Label4 = GUICtrlCreateLabel("电信网关", 384, 72, 52, 17)
$Label5 = GUICtrlCreateLabel("互联网地址", 376, 104, 64, 17)
$data = GUICtrlCreateGroup("设置", 360, 8, 257, 233)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var1="192.168.0.254"
$var2="www.163.cc"
$timeout=200
$Timer = DllCallbackRegister("pingurl", "int","hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
dim $res1
dim $res2
dim $turn=0
While 1
        $nMsg = GUIGetMsg()
if $turn==1 then       
                if BitAND($res1,$res2) Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"全部测试成功"&@CRLF," ")
EndIf
        if $res1==0 AND $res2==0 Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"全部测试失败"&@CRLF," ")
EndIf
        if $res1==1 AND $res2==0 Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"内网正常!外网失败!"&@CRLF," ")
EndIf
        if $res1==0 AND $res2==1 Then
        GUICtrlSetData ($Edit1,@MDAY&"日"&@HOUR&"时"&@MIN&"分"&@SEC&"秒-"&"外网正常!内网失败!"&@CRLF," ")
EndIf
$turn=0
EndIf
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
EndSwitch
WEnd

func pingurl($hWnd, $uiMsg, $idEvent, $dwTime)
        $res1=ping($var1,$timeout)
        $res2=ping($var2,$timeout)
        $turn=1
EndFunc
发表于 2009-12-8 11:36:32 | 显示全部楼层
呃...这个...貌似用ini,把界面去掉更方便点...
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-16 14:52 , Processed in 0.074905 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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