C# Class MouseKeyboardActivityMonitor.BaseHookListener

Base class used to implement mouse or keybord hook listeners. It provides base methods to subscribe and unsubscribe to hooks. Common processing, error handling and cleanup logic.
Inheritance: IDisposable
ファイルを表示 Open project: katopz/oskz-vcsharp

Private Properties

Property Type Description
CallNextHook int

Public Methods

Method Description
Dispose ( ) : void

Release delegates, unsubscribes from hooks.

Replace ( MouseKeyboardActivityMonitor.WinApi.Hooker hooker ) : void

Enables you to switch from application hooks to global hooks and vice versa on the fly without unsubscribing from events. Component remains enabled or disabled state after this call as it was before.

Start ( ) : void

Subscribes to the hook and starts firing events.

Stop ( ) : void

Unsubscribes from the hook and stops firing events.

Protected Methods

Method Description
BaseHookListener ( MouseKeyboardActivityMonitor.WinApi.Hooker hooker ) : System

Base constructor of BaseHookListener

Hooks are not active after instantiation. You need to use either BaseHookListener.Enabled property or call BaseHookListener.Start method.

Dispose ( bool isDisposing ) : void

Method to be used from Dispose and finalizer. Override this method to release subclass sepcific references.

GetHookId ( ) : int

Override to deliver correct id to be used for HookNativeMethods.SetWindowsHookEx call.

HookCallback ( int nCode, Int32 wParam, IntPtr lParam ) : int

A callback function which will be called every time a keyboard or mouse activity detected. WinApi.HookCallback

ProcessCallback ( int wParam, IntPtr lParam ) : bool

Override this method to modify logic of firing events.

Private Methods

Method Description
CallNextHook ( int nCode, int wParam, IntPtr lParam ) : int

Method Details

BaseHookListener() protected method

Base constructor of BaseHookListener
Hooks are not active after instantiation. You need to use either BaseHookListener.Enabled property or call BaseHookListener.Start method.
protected BaseHookListener ( MouseKeyboardActivityMonitor.WinApi.Hooker hooker ) : System
hooker MouseKeyboardActivityMonitor.WinApi.Hooker Depending on this parameter the listener hooks either application or global keyboard events.
return System

Dispose() public method

Release delegates, unsubscribes from hooks.
public Dispose ( ) : void
return void

Dispose() protected method

Method to be used from Dispose and finalizer. Override this method to release subclass sepcific references.
protected Dispose ( bool isDisposing ) : void
isDisposing bool
return void

GetHookId() protected abstract method

Override to deliver correct id to be used for HookNativeMethods.SetWindowsHookEx call.
protected abstract GetHookId ( ) : int
return int

HookCallback() protected method

A callback function which will be called every time a keyboard or mouse activity detected. WinApi.HookCallback
protected HookCallback ( int nCode, Int32 wParam, IntPtr lParam ) : int
nCode int
wParam System.Int32
lParam System.IntPtr
return int

ProcessCallback() protected abstract method

Override this method to modify logic of firing events.
protected abstract ProcessCallback ( int wParam, IntPtr lParam ) : bool
wParam int
lParam System.IntPtr
return bool

Replace() public method

Enables you to switch from application hooks to global hooks and vice versa on the fly without unsubscribing from events. Component remains enabled or disabled state after this call as it was before.
public Replace ( MouseKeyboardActivityMonitor.WinApi.Hooker hooker ) : void
hooker MouseKeyboardActivityMonitor.WinApi.Hooker An AppHooker or GlobalHooker object.
return void

Start() public method

Subscribes to the hook and starts firing events.
public Start ( ) : void
return void

Stop() public method

Unsubscribes from the hook and stops firing events.
public Stop ( ) : void
return void