;#include <ACC_Const.au3>
$EVENT_SYSTEM_MOVESIZEEND = 0x000B;窗口移动结束事件
Global $hWinEventProc = DllCallbackRegister("WinEventProc", "none", "hwnd;int;hwnd;long;long;int;int");注册回调函数
_Acc_SetWinEventHook($hWinEventProc,$EVENT_SYSTEM_MOVESIZEEND,$EVENT_SYSTEM_MOVESIZEEND);设置“最小化事件”钩子
OnAutoItExitRegister("_Exit");注册退出函数
While 1
Sleep(200)
WEnd
Func _Exit();退出程序
_Acc_UnhookWinEvent($hWinEventProc);释放钩子
Exit
EndFunc
;回调函数
Func WinEventProc($hHook, $iEvent, $hWnd, $idObject, $idChild, $iEventThread, $iEventTime);钩子,事件,句柄,对象,子ID,事件追逐,事件事件
If $iEvent = $EVENT_SYSTEM_MOVESIZEEND Then
MsgBox (0,"","窗口移动完成事件")
EndIf
EndFunc ;==>WinEventProc
Func _Acc_SetWinEventHook($hWinEvent,$event_start,$event_end,$mode=2);设置事件钩子
Local $aRet,$modeget
Local Const $WINEVENT_OUTOFCONTEXT = 0x0
Local Const $WINEVENT_SKIPOWNTHREAD = 0x1
Local Const $WINEVENT_SKIPOWNPROCESS = 0x2
Local Const $WINEVENT_INCONTEXT = 0x4
Select
Case $mode=1
$modeget=$WINEVENT_OUTOFCONTEXT;0
Case $mode=2
$modeget=$WINEVENT_SKIPOWNTHREAD;1
Case $mode=3
$modeget=$WINEVENT_SKIPOWNPROCESS;2
Case $mode=4
$modeget=$WINEVENT_INCONTEXT;4
Case $mode=5
$modeget=BitOR($WINEVENT_INCONTEXT , $WINEVENT_SKIPOWNTHREAD);5
Case $mode=6
$modeget=BitOR($WINEVENT_INCONTEXT , $WINEVENT_SKIPOWNPROCESS);6
Case Else
$modeget=2
EndSelect
$aRet = DllCall("User32.dll", "hwnd", "SetWinEventHook","uint",$event_start, _
"uint", $event_end, "hwnd", 0, "ptr", DllCallbackGetPtr($hWinEvent), _
"int", 0, "int", 0, "uint", $modeget)
If @error Or $aRet=0 Then Return SetError(1,0,0)
Return $aRet[0]
EndFunc
Func _Acc_UnhookWinEvent($hHook);解除事件钩子
DllCall("User32.dll", "int", "UnhookWinEvent", "hwnd", $hHook)
EndFunc
Func _Acc_CoInitializeEx();初始化
$aRet = DllCall("Ole32.dll", "long", "CoInitializeEx", "ptr", 0, "dword", 2)
EndFunc