EventHook 2.0.0
See the version list below for details.
dotnet add package EventHook --version 2.0.0
NuGet\Install-Package EventHook -Version 2.0.0
<PackageReference Include="EventHook" Version="2.0.0" />
<PackageVersion Include="EventHook" Version="2.0.0" />
<PackageReference Include="EventHook" />
paket add EventHook --version 2.0.0
#r "nuget: EventHook, 2.0.0"
#:package EventHook@2.0.0
#addin nuget:?package=EventHook&version=2.0.0
#tool nuget:?package=EventHook&version=2.0.0
Windows User Action Hook (EventHook)
Code Quality
A .NET library to subscribe to Windows global user actions: keyboard, mouse, clipboard, application windows, print jobs, and hotkeys.
Requires: .NET 10 on Windows (net10.0-windows). AnyCPU — works on x86, x64, and ARM64 Windows when P/Invoke pointer sizes are correct (v2 fixes these).
- API Documentation (generated DocFX site on
develop)
Install
dotnet add package EventHook
Sample
using System;
using System.Windows.Forms;
using (var eventHookFactory = new EventHookFactory())
{
var keyboardWatcher = eventHookFactory.GetKeyboardWatcher();
keyboardWatcher.Start();
keyboardWatcher.OnKeyInput += (s, e) =>
Console.WriteLine($"Key {e.KeyData.EventType} of {e.KeyData.Keyname}");
var mouseWatcher = eventHookFactory.GetMouseWatcher();
mouseWatcher.IncludeMouseMove = false; // #28
mouseWatcher.Start();
mouseWatcher.OnMouseInput += (s, e) =>
Console.WriteLine($"Mouse {e.Message} at {e.Point.x},{e.Point.y}");
var clipboardWatcher = eventHookFactory.GetClipboardWatcher();
clipboardWatcher.Start();
clipboardWatcher.OnClipboardModified += (s, e) =>
Console.WriteLine($"Clipboard {e.DataFormat}: {e.Data}");
var applicationWatcher = eventHookFactory.GetApplicationWatcher();
applicationWatcher.Start();
applicationWatcher.OnApplicationWindowChange += (s, e) =>
Console.WriteLine($"{e.ApplicationData.AppName} was {e.Event}");
var printWatcher = eventHookFactory.GetPrintWatcher();
printWatcher.Start();
printWatcher.OnPrintEvent += (s, e) =>
Console.WriteLine($"Printer {e.EventData.PrinterName} pages={e.EventData.Pages}");
var hotkeyWatcher = eventHookFactory.GetHotkeyWatcher();
hotkeyWatcher.Start();
hotkeyWatcher.Register("demo", Keys.Control | Keys.Alt | Keys.H);
hotkeyWatcher.OnHotkeyPressed += (s, e) =>
Console.WriteLine($"Hotkey {e.Id} ({e.Keys})");
Console.ReadLine();
}
Application window filter
EventHook.Helpers.AppWindowFilter.IncludeWindowsWithoutSysMenu = true; // games without WS_SYSMENU
EventHook.Helpers.AppWindowFilter.IncludeDialogs = true; // MessageBox / #32770
EventHook.Helpers.AppWindowFilter.CustomFilter = hwnd => true; // optional
Hosted apps (COM / Office add-ins)
Prefer constructing the factory on an STA UI thread, or pass an existing message-pump HWND:
using var factory = new EventHookFactory(hostMainWindowHandle);
VB.NET
See examples/EventHook.VB.Example. Context-menu paste is observed via the clipboard watcher (global); WM_PASTE itself is application-local.
Print to PDF
PrintWatcher enumerates local and connected queues, including virtual printers such as Microsoft Print to PDF. Print a document to that queue to verify OnPrintEvent.
Development
- Visual Studio 2022 / .NET 10 SDK
dotnet build src/EventHook.sln -c Releasedotnet test tests/EventHook.Testsdotnet test tests/EventHook.IntegrationTests- Docs:
dotnet tool restorethendocfx .github/docfx.json(writes API HTML underdocs/, same as titanium-web-proxy)
Release branches
| Branch | NuGet | Notes |
|---|---|---|
develop |
(no publish) | CI build + tests + DocFX |
beta |
{VersionPrefix}-beta from EventHook.csproj |
Merge develop → beta to publish prerelease |
stable / tag v* |
{VersionPrefix} from csproj |
Stable release + GitHub Pages docs |
Publishing uses NuGet Trusted Publishing (NUGET_USER on the nuget-publish environment), same pattern as titanium-web-proxy.
Version 2.0 notes
Breaking: targets net10.0-windows only (no longer .NET Framework 4.5).
Highlights: HotkeyWatcher, mouse-move filter, clipboard images/files, dialog/MsgBox tracking, PDF/virtual printers, x64/ARM64 P/Invoke fixes, reliable Stop/Dispose, GitHub Actions CI + DocFX.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on EventHook:
| Repository | Stars |
|---|---|
|
mann1x/CPUDoc
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 74 | 9/8/2026 |
| 3.0.0-beta.2 | 48 | 9/8/2026 |
| 3.0.0-beta | 71 | 9/8/2026 |
| 2.0.0 | 86 | 9/7/2026 |
| 2.0.0-beta | 87 | 8/31/2026 |
| 1.4.113 | 12,961 | 11/10/2020 |
| 1.4.110 | 948 | 10/18/2020 |
| 1.4.105 | 21,848 | 11/21/2018 |
| 1.4.79 | 2,290 | 4/24/2018 |
| 1.4.74 | 2,091 | 4/13/2018 |
| 1.4.72 | 2,031 | 4/13/2018 |
| 1.4.70 | 2,073 | 4/13/2018 |
| 1.4.67 | 2,010 | 4/13/2018 |
| 1.4.64 | 2,036 | 4/13/2018 |
| 1.4.62 | 1,968 | 4/13/2018 |
| 1.4.59 | 1,922 | 4/13/2018 |
| 1.4.58 | 1,931 | 4/13/2018 |
| 1.4.39 | 3,949 | 6/17/2016 |
| 1.4.37 | 1,812 | 4/18/2016 |
| 1.4.34 | 1,917 | 4/6/2016 |