Global Const $WA_ACTIVE = 1
Global Const $WA_CLICKACTIVE = 2
Global Const $WA_INACTIVE = 0
Global $k = 0, $j = 0
$Gui = GUICreate("WM_ACTIVATE", 550, 140, 200, 100)
GUICtrlCreateLabel('活动窗口发生 WM_ACTIVATE 消息 (最小化, 其它窗口激活).', 5, 5, 360, 130)
GUISetState()
$Gui2 = GUICreate("WM_ACTIVATE2", 550, 140, 200, 300)
GUICtrlCreateLabel('活动窗口发生 WM_ACTIVATE 消息 (最小化, 其它窗口激活).', 5, 5, 360, 130)
GUISetState()
GUIRegisterMsg(0x0006, "WM_ACTIVATE")
Do
Until GUIGetMsg() = -3
Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
Local $Active, $Minimized
$Active = BitAND($wParam, 0xFFFF) ; _WinAPI_LoWord 低位字
$Minimized = BitShift($wParam, 16) ; _WinAPI_HiWord 高位字
Switch $Active
Case $WA_ACTIVE
$out = " 通过鼠标以外的工具(如键盘)激活了该窗口"
Case $WA_CLICKACTIVE
$out = " 鼠标激活窗口"
Case $WA_INACTIVE
$out = " 取消窗口激活"
EndSwitch
If $hWnd = $Gui Then
$k += 1
WinSetTitle($Gui, '', '窗口一调用次数: ' & $k & $out)
EndIf
If $hWnd = $Gui2 Then
$j += 1
WinSetTitle($Gui2, '', '窗口二调用次数: ' & $j & $out)
EndIf
EndFunc
|