#include <WinAPI.au3>
$hGUI = GUICreate("", 400, 300)
GUICtrlCreateButton("Popup a MsgBox Window", 20, 40, 150, 20)
GUISetState(@SW_SHOW, $hGUI)
$hInst = _WinAPI_GetWindowLong($hGUI, -6)
$iThreadId = _WinAPI_GetCurrentThreadId()
$hCallBack = DllCallBackRegister("_CallBack", "int", "int;hWnd;ptr")
$pCallBack = DllCallBackGetPtr($hCallBack)
$hHook = _WinAPI_SetWindowsHookEx(5, $pCallBack, $hInst, $iThreadId)
While 1
Switch GUIGetMsg()
Case -3
ExitLoop
Case 3
MsgBox(0, "Popup a MsgBox Window", "Locates at Left-top corner")
EndSwitch
WEnd
GUIDelete($hGUI)
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallBackFree($hCallBack)
Func _CallBack($iCode, $wParam, $lParam)
If ($iCode = 5) And ($wParam <> $hGUI) Then
WinMove($wParam, "", 0, 0, Default, Default)
EndIf
Return 0
EndFunc ;==>_CallBack
|