找回密码
 加入
搜索
查看: 6685|回复: 7

[AU3基础] [已解决]GUI界面循环按钮和注册的函数冲突怎么解决

  [复制链接]
发表于 2013-8-3 11:53:27 | 显示全部楼层 |阅读模式
本帖最后由 qq1244521 于 2013-8-10 12:48 编辑

我弄了个小工具 有一项时刻观察网络PING值 但是放到GUI界面的按钮循环中 其他按钮 有时好使有时不好使  我想注册个函数自己定时去更新GUI界面上的PING数值 但是却彻底不好使了
这样的情况能放到一个程序里吗?  还是需要另编辑个 对接程序 我还是个小鸟 暂时这些完成不了

还请赐教
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Local $var $var1



#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\form1.kxf
$Form1_1 = GUICreate("Form1", 418, 412, 357, 158)
$Tab1 = GUICtrlCreateTab(0, 0, 417, 361)
$TabSheet1 = GUICtrlCreateTabItem("计划任务")
$Checkbox1 = GUICtrlCreateCheckbox("开机启动程序", 32, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("记录运行日志", 32, 88, 105, 17)
$Checkbox3 = GUICtrlCreateCheckbox("断电自动关机", 32, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("定期重启服务器", 32, 200, 113, 17)
$Radio1 = GUICtrlCreateRadio("指定", 32, 240, 49, 17)
$Radio2 = GUICtrlCreateRadio("每周", 32, 272, 49, 17)
$Radio3 = GUICtrlCreateRadio("每月", 32, 304, 57, 17)
$Group2 = GUICtrlCreateGroup("计划任务", 16, 176, 385, 161)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Combo1 = GUICtrlCreateCombo("Combo1", 104, 240, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("Combo2", 184, 240, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlCreateCombo("Combo3", 272, 240, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo4 = GUICtrlCreateCombo("Combo4", 104, 272, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo5 = GUICtrlCreateCombo("Combo5", 184, 272, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo6 = GUICtrlCreateCombo("Combo6", 272, 272, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo7 = GUICtrlCreateCombo("Combo7", 104, 304, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo8 = GUICtrlCreateCombo("Combo8", 184, 304, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo9 = GUICtrlCreateCombo("Combo9", 272, 304, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$TabSheet2 = GUICtrlCreateTabItem("监控中心")
GUICtrlSetState(-1,$GUI_SHOW)
$Label11= GUICtrlCreateLabel ( "", 72, 272 , 40 , 17  )
$Label12= GUICtrlCreateLabel ( "", 72, 232 , 40 , 17  )
$Label1 = GUICtrlCreateLabel("名称:", 24, 72, 40, 17)
$Label2 = GUICtrlCreateLabel("系统:", 24, 104, 40, 17)
$Label3 = GUICtrlCreateLabel("I P:", 24, 136, 38, 17)
$Label4 = GUICtrlCreateLabel("内网:", 24, 232, 40, 17)
$Label5 = GUICtrlCreateLabel("外网:", 24, 272, 40, 17)
$Group3 = GUICtrlCreateGroup("本机信息", 16, 48, 385, 129)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("网络信息", 16, 208, 385, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet3 = GUICtrlCreateTabItem("维护工具")
$Button3 = GUICtrlCreateButton("Button3", 34, 55, 90, 30)
$Button4 = GUICtrlCreateButton("Button4", 164, 55, 90, 30)
$Button5 = GUICtrlCreateButton("Button5", 294, 55, 90, 30)
$Button6 = GUICtrlCreateButton("Button6", 34, 115, 90, 30)
$Button7 = GUICtrlCreateButton("Button7", 164, 115, 90, 30)
$Button8 = GUICtrlCreateButton("Button8", 294, 115, 90, 30)
$Button9 = GUICtrlCreateButton("Button9", 34, 175, 90, 30)
$Button10 = GUICtrlCreateButton("Button10", 164, 175, 90, 30)
$Button11 = GUICtrlCreateButton("Button11", 294, 175, 90, 30)
$Button12 = GUICtrlCreateButton("Button12", 34, 235, 90, 30)
$Button13 = GUICtrlCreateButton("Button13", 164, 235, 90, 30)
$Button14 = GUICtrlCreateButton("Button14", 294, 235, 90, 30)
$Button15 = GUICtrlCreateButton("Button15", 34, 295, 90, 30)
$Button16 = GUICtrlCreateButton("Button16", 164, 295, 90, 30)
$Button17 = GUICtrlCreateButton("Button17", 294, 295, 90, 30)
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("隐藏程序", 165, 368, 90, 30)
$Button2 = GUICtrlCreateButton("退出程序", 295, 368, 90, 30)
$Label6 = GUICtrlCreateLabel("本程序只支持易游服务器", 8, 376, 136, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

AdlibRegister("LAN",1000)
AdlibRegister("WAN",1000)

While 1
        
        Sleep ( 1000 )
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        AdlibUnRegister ( "LAN" )
                        AdlibUnRegister ( "WAN" )
                        Exit
                Case $Button2
                        AdlibUnRegister ( "LAN" )
                        AdlibUnRegister ( "WAN" )
                        Exit
        EndSwitch

WEnd


Func LAN()
$var = Ping("192.168.1.1", 250)

If $var  Then
    GUICtrlSetData($Label12,$var&"ms")
        Else
    If  @error = 1 Then
        MsgBox(4096, "", "192.168.1.1丢包")
        ElseIf @error = 2 Then
    MsgBox(4096, "", "网卡被拔出")

    EndIf
EndIf
EndFunc


Func WAN()
        
$var1 = Ping("202.96.64.68", 250)

If $var1  Then
        
    GUICtrlSetData($Label11,$var&"ms")
        Else
    If  @error = 1 Then
        MsgBox(4096, "", "202.96.64.68丢包")
        ElseIf @error = 2 Then
    MsgBox(4096, "", "网卡被拔出")

    EndIf
EndIf

EndFunc
脚本不算完整 我暂时只到这就写不下去了
发表于 2013-8-3 12:06:40 | 显示全部楼层
在LAN()WAN()函数中,根据PING情况,直接GuiCtrlSetData,错误的话也GuiCtrlSetData不要用msgBox
 楼主| 发表于 2013-8-3 13:35:43 | 显示全部楼层
回复 2# seniors


    我这只是暂时备用测试功能是否好使 将来会改成记录掉线的时间 网线被拔出时间过长会自动关机
 楼主| 发表于 2013-8-3 13:36:28 | 显示全部楼层
这个应该不影响到我的整个循环失效吧
发表于 2013-8-3 18:27:25 | 显示全部楼层
开两个程序在Ping, Ping的结果放在一个文件里,你再弄个主程序去读取这个数据。
这样都不会相互干扰了。
发表于 2013-8-3 20:25:24 | 显示全部楼层
把sleep(1000)去掉
发表于 2013-8-3 20:27:34 | 显示全部楼层
回复 4# qq1244521
等一直跳msgbox时你就难受了
 楼主| 发表于 2013-8-10 12:42:37 | 显示全部楼层
回复 6# seniors

非常感谢 seniors 延时去掉后效果好多了 MSG 我是留做备用的检测效果好使不 继续完善会直接写入文本做记录就行
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 23:34 , Processed in 0.098180 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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