I am testing HookEvent function, downloaded from this site.
The function is:
Code: Select all
HookEvent( sFunctionName, aiEvents, sPID := "0", iFlags := "0" )
{
Global sEventHookTable
For i, Event_ID in aiEvents
{
If( !sEventHookTable[ Event_ID ] )
sEventHookTable[ Event_ID ] := Array()
If( CreateWinEventHook( sFunctionName, Event_ID, sPID, iFlags ))
sEventHookTable[ Event_ID ].Push( sFunctionName )
}
}
CreateWinEventHook( sFunctionName, iEvent, sPIDs := "0", dwFlags := "0" )
{
Global _hHookTable
cb := RegisterCallback( sFunctionName )
DeleteWinEventHook( sFunctionName, iEvent )
DllCall( "CoInitialize", UInt, 0 )
If( hHook := DllCall( "SetWinEventHook", UInt, iEvent, UInt, iEvent, UInt, 0, UInt, cb, UInt, sPIDs, UInt, 0, UInt, dwFlags ))
_hHookTable[ sFunctionName . "_" . iEvent ] := hHook
Return !!hHook
}
DeleteWinEventHook( sFunctionName, iEvent )
{
Global _hHookTable
hHook := _hHookTable.Delete( sFunctionName . "_" . iEvent )
Return ( hHook != 0 ? DllCall( "UnhookWinEvent", UInt, hHook ) : False )
}
on the CreateWinEventHook(...) function, why use DeleteWinEventHook(...) to delete an old hook before generate a new hook?
Is no possible to generate a new hook wihout delete an old hook?
Thank you very much.