因为没有与程序相关的软件,仅是猜测.
问题不是出在消息模式上,而是出在32行开始的循环上.因为AU3不支持多线程,所以只能提高响应级别来对循环进行中断.代码思路如下,不知道有没有帮助.
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $Flg = True
Global $Click = 0
Local $t = 0
$Form1 = GUICreate("Form1", 318, 120, 468, 171)
GUISetOnEvent(-3, "_exit")
$Button1 = GUICtrlCreateButton("开始循环", 48, 60, 80, 40)
GUICtrlSetOnEvent(-1, "Click")
$Lable = GUICtrlCreateLabel("", 208, 60, 80, 40)
;$Button2 = GUICtrlCreateButton("结束循环", 208, 60, 80, 40)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
Sleep(100)
WEnd
Func _exit()
Exit
EndFunc ;==>_exit
Func Click()
If GUICtrlRead($Button1) = "开始循环" And $Flg = True Then
GUICtrlSetData($Button1, "结束循环")
$Click += 1
GUICtrlSetData($Lable, "执行第" & $Click & "次循环")
TEST()
Else
GUICtrlSetData($Button1, "开始循环")
EndIf
EndFunc ;==>Click
Func TEST()
While $Flg
ToolTip($t)
$t += 1
WEnd
$Flg = True
$t = 0
EndFunc ;==>TEST
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
|