[This is preliminary documentation and is subject to change.]

Base class for classes used to handle Win32 hooks

Namespace: Tools.API.Hooks
Assembly: Tools.Win (in Tools.Win.dll) Version: 1.5.3.38916 (1.5.3.38916)

Syntax

C#
[DefaultBindingPropertyAttribute("KeyEvent")]
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
public abstract class Win32Hook : IDisposable
Visual Basic
<DefaultBindingPropertyAttribute("KeyEvent")> _
<EditorBrowsableAttribute(EditorBrowsableState.Advanced)> _
Public MustInherit Class Win32Hook _
	Implements IDisposable
Visual C++
[DefaultBindingPropertyAttribute(L"KeyEvent")]
[EditorBrowsableAttribute(EditorBrowsableState::Advanced)]
public ref class Win32Hook abstract : IDisposable
F#
[<AbstractClassAttribute>]
[<DefaultBindingPropertyAttribute("KeyEvent")>]
[<EditorBrowsableAttribute(EditorBrowsableState.Advanced)>]
type Win32Hook =  
    class
        interface IDisposable
    end
JScript
public abstract class Win32Hook implements IDisposable

Remarks

It is highly recomended not to install multiple hooks of same type in one application and to keep hook-handling code as quick as possible. You can significantly slow down user typing experience.

This class uses Win32 API function SetWindowsHookEx().

.NET framework basically does not support global hooks to be installed. Mouse and keyboard low-level hooks implemented in LowLevelMouseHook and LowLevelKeyboardHook are the only exception. In case you'll implement hook for example for WH_KEYBOARD, you will receive callbacks only as long as your application will be foreground one. The only workaround to this limitation is to have callback function in unmanaged DLL.

For more informations see SetWindowsHookEx FunctionProcessing Global Mouse and Keyboard Hooks in C# and How to set a Windows hook in Visual C# .NET.

Inheritance Hierarchy

See Also