GUI循环请教
本帖最后由 kkck 于 2009-7-15 14:56 编辑#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 292, 102, 832, 578)
$Button1 = GUICtrlCreateButton("1", 24, 24, 97, 41, $WS_GROUP)
$Button2 = GUICtrlCreateButton("2", 144, 24, 113, 41, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
a()
Case $Button2
b()
EndSwitch
WEnd
Func a()
While 1
Sleep(1000)
WEnd
EndFunc
Func b()
While 1
Sleep(1000)
WEnd
EndFunc当a按钮运行后就不能运行b按钮(先按b,a就不能执行了) 窗口也不能关闭只能结束进程
怎样才能解决 请使用事件模式。。。。 "ControlDisable"
"ControlEnable"
看看这2个函数能帮到你不,自己研究下吧! 请使用事件模式。。。。
大绯狼 发表于 2009-7-13 23:15 http://www.autoitx.com/images/common/back.gif#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("窗体1", 322, 130, 830, 320)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Button1", 56, 24, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 200, 40, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Button1Click()
While 1
MsgBox(0,"1","1")
Sleep(3000)
WEnd
EndFunc
Func Button2Click()
While 1
MsgBox(0,"2","2")
Sleep(3000)
WEnd
EndFunc
Func Form1Close()
Exit
EndFunc
还是按完第一个按钮后就不能用第二个按钮
也不能用右上角的叉来关闭
请你运行上面的代码试试 #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("窗体1", 322, 130, 830, 320)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Button1", 56, 24, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Button2", 200, 40, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func Button1Click()
MsgBox(0,"1","1")
EndFunc
Func Button2Click()
MsgBox(0,"2","2")
EndFunc
Func Form1Close()
Exit
EndFunc看看这个是不是你想要的效果 首先谢谢楼上的帮忙
也许我真没表达清楚
Func Button1Click()
MsgBox(0,"1","1")
EndFunc
这样只是跳一个提示吧
我想要的效果是当只按下button1click时
反复的执行MsgBox(0,"1","1")
当按下button2click时
反复的执行MsgBox(0,"2","2")
即终止了MsgBox(0,"1","1")的执行
所以加这个
while 1
wend
才能循环
现在遇到的是程序会一直循环在第一次按下的命令上 我也想知道怎么做,大侠说一下啊! #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 292, 102, 832, 578)
$Button1 = GUICtrlCreateButton("1", 24, 24, 97, 41, $WS_GROUP)
$Button2 = GUICtrlCreateButton("2", 144, 24, 113, 41, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
a()
Case $Button2
b()
EndSwitch
WEnd
Func a()
While 1
if GUIGetMsg() = $Button2 then b()
Sleep(1000)
WEnd
EndFunc
Func b()
While 1
Sleep(1000)
WEnd
EndFunc 都没解决这个问题,怎么就关了呢?
页:
[1]