如何关闭这个程式?
本帖最后由 faceyao 于 2009-6-30 18:56 编辑点了确定后,就开始循环了,但是再点右上角的X“关闭"按钮却无效,仍然继续运行,请问如何写代码才能让这个右上角的X有效,也就是点这个X循环就终止循环并关闭软件?#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 157, 59, 192, 124)
$Button1 = GUICtrlCreateButton("确定", 16, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
While 1
MsgBox (0,"","你点击了【确定】按钮")
Sleep(4000)
WEnd
EndSwitch
WEnd
MsgBox (0,"","你点击了【确定】按钮")
先说啊!我也是是新手,如果有说错的地方请多包含
我觉得可以将MsgBox (0,"","")改成MsgBox (1,"","")吧!
这样就有确定和取消,在赋予取消的命令应该就可以了。
只是思路具体看你自己啦 MsgBox (0,"","你点击了【确定】按钮")
先说啊!我也是是新手,如果有说错的地方请多包含
我觉得可以将MsgBox (0,"","")改成MsgBox (1,"","")吧!
这样就有确定和取消,在赋予取消的命令应该就可以了。
只是思路 ...
水木子 发表于 2009-6-30 17:45 http://www.autoitx.com/images/common/back.gif
不是,必须要按下右上角X关闭按钮才做退出,和msgbox没关系,msgbox只是举例而已 用热键 HotKeySet #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Dim $start = 0, $ostart
$Form1 = GUICreate("Form1", 157, 59, 192, 124)
$Button1 = GUICtrlCreateButton("确定", 16, 16, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "gui")
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUISetState(@SW_SHOW)
While 1
If $start = 1 Then
MsgBox(0, "", "你点击了【确定】按钮")
Sleep(4000)
EndIf
WEnd
Exit
Func gui()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
$start = 0
Exit
Case $Button1
$start = 1
EndSwitch
EndFunc ;==>gui
de] 本帖最后由 autoit3CN 于 2009-6-30 18:35 编辑
#include <GUIConstants.au3>
#include <Timers.au3>
$Form = GUICreate("例子一", 307, 81, -1, -1)
$Button1 = GUICtrlCreateButton("开始", 32, 24, 97, 33, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Dim $i=0
$iTimeProgres4 = _Timer_SetTimer($Form ,4000,'fit')
EndSwitch
WEnd
Func fit($hWnd, $iMsg, $iwParam, $ilParam)
MsgBox (1,"","你点击了【确定】按钮")
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox (0,"","你点击了【确定】按钮")
EndSwitch
WEnd 无限循环中套用无限循环行吗?
我不知..... 谢谢5楼“即即 ”和6楼“autoit3CN ”,经尝试,你们的代码都解决了俺的问题,谢谢!!
也谢谢“131738 ”“afan”,“水木子 ”的热心帮助,TKS!
已解决!
页:
[1]