H.Hooks 1.4.12
H.Hooks
It uses Win32 kernel32.dll and user32.dll calls inside.
Nuget
Install-Package H.Hooks
Usage
using var keyboardHook = new LowLevelKeyboardHook();
keyboardHook.Up += (_, args) => Console.WriteLine($"{nameof(keyboardHook.Up)}: {args}");
keyboardHook.Down += (_, args) => Console.WriteLine($"{nameof(keyboardHook.Down)}: {args}");
keyboardHook.Start();
using var mouseHook = new LowLevelMouseHook();
mouseHook.Down += (_, args) => Console.WriteLine($"{nameof(mouseHook.Down)}: {args}");
mouseHook.Move += (_, args) => Console.WriteLine($"{nameof(mouseHook.Move)}: {args}");
mouseHook.Start();
Interception of input and cancellation
Allows you to intercept input for other applications and cancel events (via args.IsHandled = true).
Do not enable this unless you need it.
When enabled, overrides the automatic dispatch of events to the ThreadPool
and may cause performance issues with any slow handlers. In this case,
you need to use ThreadPool.QueueUserWorkItem(WaitCallback)
when handling events (after set up args.IsHandled = true).
hook.Handling = true;
hook.Up += (_, args) => args.IsHandled = true;
Advanced usage
// Enables Move events.
mouseHook.GenerateMouseMoveEvents = true;
// Adds keyboard keys. Allows getting combinations like Shift + LeftMouse.
mouseHook.AddKeyboardKeys = true;
// Sends multiple events while key pressed.
keyboardHook.OneUpEvent = false;
// Allows handle modifier keys.
keyboardHook.HandleModifierKeys = true;
// Allows common key combinations, like 1 + 2 + 3.
hook.IsExtendedMode = true;
// Events will contains separate Left/Right keys.
hook.IsLeftRightGranularity = true;
// Uses User32.GetKeyboardState instead User32.GetKeyState.
// Disable this if any problem.
hook.UseKeyboardState = false;
// Adds Key.Caps to each event if CapsLock is toggled.
hook.IsCapsLock = false;
Contacts
Showing the top 20 packages that depend on H.Hooks.
| Packages | Downloads |
|---|---|
|
Lib.KeyboardEvent
Package Description
|
12 |
|
Lib.KeyboardEvent
Package Description
|
10 |
|
Lib.KeyboardEvent
Package Description
|
1 |
| Version | Downloads | Last updated |
|---|---|---|
| 1.7.0 | 13 | 02/19/2025 |
| 1.6.0 | 12 | 02/19/2025 |
| 1.4.21 | 12 | 02/19/2025 |
| 1.4.20 | 12 | 02/19/2025 |
| 1.4.19 | 12 | 02/19/2025 |
| 1.4.18 | 10 | 02/19/2025 |
| 1.4.17 | 10 | 02/19/2025 |
| 1.4.14 | 11 | 02/19/2025 |
| 1.4.13 | 10 | 02/19/2025 |
| 1.4.12 | 10 | 02/19/2025 |
| 1.4.9 | 10 | 02/19/2025 |
| 1.4.8 | 10 | 02/19/2025 |
| 1.4.7 | 10 | 02/19/2025 |
| 1.4.6 | 10 | 02/19/2025 |
| 1.4.5 | 10 | 02/19/2025 |
| 1.4.3 | 10 | 02/19/2025 |
| 1.3.2 | 10 | 02/19/2025 |
| 1.3.1 | 10 | 02/19/2025 |
| 1.3.0 | 10 | 02/19/2025 |
| 1.2.4 | 10 | 02/19/2025 |
| 1.2.3 | 10 | 02/19/2025 |
| 1.2.2 | 10 | 02/19/2025 |
| 1.2.1 | 10 | 02/19/2025 |
| 1.2.0 | 11 | 02/19/2025 |
| 1.1.0 | 10 | 02/19/2025 |
| 1.0.1 | 11 | 02/19/2025 |
| 1.0.0 | 10 | 02/19/2025 |