找回密码
 加入
搜索
查看: 3690|回复: 5

[GUI管理] 【已解决】循环一个按钮下的代码 GU无法退出

  [复制链接]
发表于 2010-8-7 11:10:06 | 显示全部楼层 |阅读模式
本帖最后由 261869247 于 2010-8-7 11:24 编辑
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\服务器信息\form1.kxf
FileInstall("serverInf.dll", @TempDir & "\serverInf.dll", 1)

$Form1_1 = GUICreate("服务器基本信息获取", 280, 288, 330, 280)
$Input1 = GUICtrlCreateInput("121.8.187.110:27015", 16, 32, 201, 21)
$Label1 = GUICtrlCreateLabel("服务器IP地址", 16, 8, 74, 17)
$Button1 = GUICtrlCreateButton("查询", 224, 32, 41, 25)

$Group1 = GUICtrlCreateGroup("服务器基本信息", 16, 64, 249, 201)
$Label2 = GUICtrlCreateLabel("服务器名字", 24, 88, 64, 17)
$Label3 = GUICtrlCreateLabel("服务器延时", 24, 128, 64, 17)
$Label4 = GUICtrlCreateLabel("服务器地图", 24, 152, 64, 17)
$Label5 = GUICtrlCreateLabel("服务器人数", 24, 176, 64, 17)

$Label6 = GUICtrlCreateLabel("", 88, 88, 170, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
$Label7 = GUICtrlCreateLabel("", 88, 128, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$Label8 = GUICtrlCreateLabel("", 88, 152, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label9 = GUICtrlCreateLabel("", 88, 176, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ExitLoop
                        Exit
                Case $Button1  ;循环这个按钮下的代码 无法退出 郁闷                        While 1
                                Dim $ipaddress, $inf
                                $ipaddress = GUICtrlRead($Input1)
                                DllOpen(@TempDir & "\serverInf.dll")
                                $inf = DllCall(@TempDir & "\serverInf.dll", "str", "Inquiry", "str", $ipaddress)
                                ;If @error = 0 Then MsgBox(0, "", $inf[0])
                                $aSplit = StringSplit($inf[0], "", 1)
                                GUICtrlSetData($Label6, $aSplit[1])
                                GUICtrlSetData($Label8, $aSplit[2])
                                GUICtrlSetData($Label7, $aSplit[3])
                                GUICtrlSetData($Label9, $aSplit[4] & '/' & $aSplit[5])
                                DllClose($inf)
                                Sleep(1000)
                        WEnd
        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-8-7 11:11:58 | 显示全部楼层
在消息循环中没有跳出循环的条件
 楼主| 发表于 2010-8-7 11:22:19 | 显示全部楼层
解决了
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\服务器信息\form1.kxf
FileInstall("serverInf.dll", @TempDir & "\serverInf.dll", 1)

$Form1_1 = GUICreate("服务器基本信息获取", 280, 288, 330, 280)
$Input1 = GUICtrlCreateInput("121.8.187.110:27015", 16, 32, 201, 21)
$Label1 = GUICtrlCreateLabel("服务器IP地址", 16, 8, 74, 17)
$Button1 = GUICtrlCreateButton("查询", 224, 32, 41, 25)

$Group1 = GUICtrlCreateGroup("服务器基本信息", 16, 64, 249, 201)
$Label2 = GUICtrlCreateLabel("服务器名字", 24, 88, 64, 17)
$Label3 = GUICtrlCreateLabel("服务器延时", 24, 128, 64, 17)
$Label4 = GUICtrlCreateLabel("服务器地图", 24, 152, 64, 17)
$Label5 = GUICtrlCreateLabel("服务器人数", 24, 176, 64, 17)

$Label6 = GUICtrlCreateLabel("", 88, 88, 170, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
$Label7 = GUICtrlCreateLabel("", 88, 128, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$Label8 = GUICtrlCreateLabel("", 88, 152, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label9 = GUICtrlCreateLabel("", 88, 176, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1  ;循环这个按钮无法退出
                        AdlibRegister('serverInf', 1000)
        EndSwitch
WEnd


Func serverInf()
                                Dim $ipaddress, $inf
                                $ipaddress = GUICtrlRead($Input1)
                                $inf = DllCall(@TempDir & "\serverInf.dll", "str", "Inquiry", "str", $ipaddress)
                                ;If @error = 0 Then MsgBox(0, "", $inf[0])
                                $aSplit = StringSplit($inf[0], "", 1)
                                GUICtrlSetData($Label6, $aSplit[1])
                                GUICtrlSetData($Label8, $aSplit[2])
                                GUICtrlSetData($Label7, $aSplit[3])
                                GUICtrlSetData($Label9, $aSplit[4] & '/' & $aSplit[5])
EndFunc
发表于 2010-8-7 11:24:22 | 显示全部楼层
Case $Button1
                        AdlibRegister('serverInf', 1000)
                        serverInf() ;加一行
 楼主| 发表于 2010-8-7 11:26:45 | 显示全部楼层
本帖最后由 261869247 于 2010-8-7 11:27 编辑

好的我试试
不知道还有别的方法 刚才afan 提到的跳出循环
发表于 2010-8-7 11:37:32 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\服务器信息\form1.kxf
FileInstall("serverInf.dll", @TempDir & "\serverInf.dll", 1)

$Form1_1 = GUICreate("服务器基本信息获取", 280, 288, 330, 280)
GUISetOnEvent(-3, "_exit")
$Input1 = GUICtrlCreateInput("121.8.187.110:27015", 16, 32, 201, 21)
$Label1 = GUICtrlCreateLabel("服务器IP地址", 16, 8, 74, 17)
$Button1 = GUICtrlCreateButton("查询", 224, 32, 41, 25)

$Group1 = GUICtrlCreateGroup("服务器基本信息", 16, 64, 249, 201)
$Label2 = GUICtrlCreateLabel("服务器名字", 24, 88, 64, 17)
$Label3 = GUICtrlCreateLabel("服务器延时", 24, 128, 64, 17)
$Label4 = GUICtrlCreateLabel("服务器地图", 24, 152, 64, 17)
$Label5 = GUICtrlCreateLabel("服务器人数", 24, 176, 64, 17)

$Label6 = GUICtrlCreateLabel("", 88, 88, 170, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
$Label7 = GUICtrlCreateLabel("", 88, 128, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$Label8 = GUICtrlCreateLabel("", 88, 152, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label9 = GUICtrlCreateLabel("", 88, 176, 170, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        Opt('GUIOnEventMode', 1)
                        While 1
                                Local $ipaddress, $inf
                                $ipaddress = GUICtrlRead($Input1)
                                $inf = DllCall(@TempDir & "\serverInf.dll", "str", "Inquiry", "str", $ipaddress)
                                $aSplit = StringSplit($inf[0], "", 1)
                                GUICtrlSetData($Label6, $aSplit[1])
                                GUICtrlSetData($Label8, $aSplit[2])
                                GUICtrlSetData($Label7, $aSplit[3])
                                GUICtrlSetData($Label9, $aSplit[4] & '/' & $aSplit[5])
                                Sleep(1000)
                        WEnd
        EndSwitch
WEnd

Func _exit()
        exit
Endfunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 19:39 , Processed in 0.085247 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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