回答不只一次了
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $Flg = True
Local $t = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 318, 120, 468, 171)
$Button1 = GUICtrlCreateButton("开始循环", 48, 60, 80, 40)
;$Button2 = GUICtrlCreateButton("结束循环", 208, 60, 80, 40)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
$msg=GUIGetMsg()
Switch $msg
case -3
Exit
Case $Button1
if GUICtrlRead($Button1)="开始循环" and $Flg=True Then
GUICtrlSetData($Button1,"结束循环")
TEST()
Else
GUICtrlSetData($Button1,"开始循环")
EndIf
EndSwitch
WEnd
Func TEST()
While $Flg
ToolTip($t)
$t+=1
WEnd
$Flg=True
$t=0
EndFunc
Func WM_COMMAND($hWnd, $msg, $wParam, $lParam)
#forceref $hWnd, $Msg
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)
Local $hCtrl = $lParam
Switch $hCtrl
Case GUICtrlGetHandle($Button1)
if GUICtrlRead($Button1)="结束循环" then
$Flg=False
Else
$Flg=True
EndIf
EndSwitch
EndFunc ;==>WM_COMMAND
|