这样写肯定反应慢了。
你把主程序放在WHILE里面,不断的循环运行,那两个按钮是干啥用的?把主程序放在按钮事件里面不行吗?
下面代码改成了事件模式#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1) ;切换至 事件模式
$Form1 = GUICreate("Form1", 623, 442)
GUISetOnEvent($GUI_EVENT_CLOSE, "g")
$Button1 = GUICtrlCreateButton("Button1", 40, 32, 75, 25)
GUICtrlSetOnEvent(-1, "g")
$Button2 = GUICtrlCreateButton("Button2", 136, 32, 75, 25)
GUICtrlSetOnEvent(-1, "g")
GUISetState(@SW_SHOW)
While 1
Sleep(1000)
ToolTip(@HOUR &":"& @MIN &":"& @SEC, @DesktopWidth/2, @DesktopHeight/2, "主程序运行中")
WEnd
Func g()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0, 0, "button1被按下")
Case $Button2
MsgBox(0, 0, "button2被按下")
EndSwitch
EndFunc ;==>g
|