【已解决】循环一个按钮下的代码 GU无法退出
本帖最后由 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)
$aSplit = StringSplit($inf, "\", 1)
GUICtrlSetData($Label6, $aSplit)
GUICtrlSetData($Label8, $aSplit)
GUICtrlSetData($Label7, $aSplit)
GUICtrlSetData($Label9, $aSplit & '/' & $aSplit)
DllClose($inf)
Sleep(1000)
WEnd
EndSwitch
WEnd
在消息循环中没有跳出循环的条件 解决了#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)
$aSplit = StringSplit($inf, "\", 1)
GUICtrlSetData($Label6, $aSplit)
GUICtrlSetData($Label8, $aSplit)
GUICtrlSetData($Label7, $aSplit)
GUICtrlSetData($Label9, $aSplit & '/' & $aSplit)
EndFunc
Case $Button1
AdlibRegister('serverInf', 1000)
serverInf() ;加一行 本帖最后由 261869247 于 2010-8-7 11:27 编辑
好的我试试
不知道还有别的方法 刚才afan 提到的跳出循环 #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, "\", 1)
GUICtrlSetData($Label6, $aSplit)
GUICtrlSetData($Label8, $aSplit)
GUICtrlSetData($Label7, $aSplit)
GUICtrlSetData($Label9, $aSplit & '/' & $aSplit)
Sleep(1000)
WEnd
EndSwitch
WEnd
Func _exit()
exit
Endfunc
页:
[1]