【已解决】按了GUI里一个控件后其它控件怎么就失效
本帖最后由 tryhi 于 2010-6-26 13:53 编辑#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 318, 120, 468, 171)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("开始", 8, 84, 57, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button4 = GUICtrlCreateButton("退出", 238, 84, 57, 25)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Ab()
Sleep(100000)
EndFunc
Func Button1Click()
ab()
EndFunc
Func Button2Click()
Exit
EndFunc
Func Form1Close()
Exit
EndFunc
像这个,运行后点退出按钮就可以退出,但运行后点开始按钮,再点退出就没反应了
怎样才能在点击了开始之后还能点退出按钮 还没睡,你有狠 回复 1# tryhi
事实上程序已经接受了你的关闭请求。
只是,AU3没有多线程, 你睡眠100秒后,才轮到退出代码的执行。 想知道吗?先把代码的格式缩进改了再说。凌乱至极。 #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 318, 120, 468, 171)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("开始", 8, 84, 57, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button4 = GUICtrlCreateButton("退出", 238, 84, 57, 25)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Ab()
Sleep(100)
EndFunc
Func Button1Click()
ab()
EndFunc
Func Button2Click()
Exit
EndFunc
Func Form1Close()
Exit
EndFunc
看看行不行! 楼上的不行,你把时间改那么短当然可以,问题我已经解决了 #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $Flg=False
Local $t=0
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 318, 120, 468, 171)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("开始", 8, 84, 57, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button4 = GUICtrlCreateButton("退出", 238, 84, 57, 25)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
If $Flg=True Then
Ab()
Else
Sleep(200)
EndIf
WEnd
Func Ab()
Sleep(100000)
EndFunc
Func Button1Click()
$Flg=True
EndFunc
Func Button2Click()
Exit
EndFunc
Func Form1Close()
Exit
EndFunc
页:
[1]