Show / Hide Table of Contents

Method WinEventHook.Add


Overload

Adds a hook for an event or a range of events.

public int Add(EEvent eventMin, EEvent eventMax = 0, int idProcess = 0, int idThread = 0, EHookFlags flags = EHookFlags.None)
Parameters
eventMin  (EEvent)

The lowest event constant value in the range of events. Can be EEvent.MIN to indicate the lowest possible event value. Events reference: SetWinEventHook. Value 0 is ignored.

eventMax  (EEvent)

The highest event constant value in the range of events. Can be EEvent.MAX to indicate the highest possible event value. If 0, uses eventMin.

idProcess  (int)

The id of the process from which the hook function receives events. If 0 - all processes on the current desktop.

idThread  (int)

The native id of the thread from which the hook function receives events. If 0 - all threads.

flags  (EHookFlags)
Returns
int

An int value greater than 0 that can be used with WinEventHook.Remove.

Exceptions
AuException

Failed.

Remarks

Parameters are the same as of the constructor, but values can be different.

This function together with WinEventHook.Remove can be used to temporarily add/remove one or more hooks while using the same WinEventHook variable and hook procedure. Don't need to call Unhook before.

Examples

See WinEventHook.