How about this?
 
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>
Example()
Func Example()
	Local $hGUI = GUICreate("Testing WM_ACTIVATEAPP", 400, 60, -1, -1, $WS_OVERLAPPEDWINDOW)
	Local $idButton_1 = GUICtrlCreateButton("Button 1", 100, 15, 80, 25)
	Local $idButton_Close = GUICtrlCreateButton("Close", 215, 15, 80, 25)
	ConsoleWrite("$hGUI = " & $hGUI & @CRLF & @CRLF)
	GUIRegisterMsg($WM_ACTIVATEAPP, "WM_ACTIVATEAPP")
	GUISetState(@SW_SHOW, $hGUI)
	While 1
		Switch GUIGetMsg()
			Case $GUI_EVENT_CLOSE, $idButton_Close
				ExitLoop
			Case $idButton_1
				MsgBox($MB_TOPMOST, "Title", "Button_1 pressed")
		EndSwitch
	WEnd
	GUIDelete($hGUI)
EndFunc   ;==>Example
;=================================================
Func WM_ACTIVATEAPP($hWnd, $iMsg, $wParam, $lParam)
	Local Static $iCount
	$iCount += 1
	ConsoleWrite($iCount & " WM_ACTIVATEAPP  : $hWnd = " & $hWnd & "   $wParam = " & $wParam & "   $lParam = " & $lParam & @CRLF)
	Local $hWnd_Active = WinGetHandle("[ACTIVE]", "")
	ConsoleWrite($hWnd_Active & @TAB & WinGetTitle($hWnd_Active) & @CRLF)
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_ACTIVATEAPP