NonInvasiveKeyboardHookLibrary.Core 2.1.0

.NET Core 3.1
dotnet add package NonInvasiveKeyboardHookLibrary.Core --version 2.1.0
NuGet\Install-Package NonInvasiveKeyboardHookLibrary.Core -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NonInvasiveKeyboardHookLibrary.Core" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NonInvasiveKeyboardHookLibrary.Core --version 2.1.0
#r "nuget: NonInvasiveKeyboardHookLibrary.Core, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NonInvasiveKeyboardHookLibrary.Core as a Cake Addin
#addin nuget:?package=NonInvasiveKeyboardHookLibrary.Core&version=2.1.0

// Install NonInvasiveKeyboardHookLibrary.Core as a Cake Tool
#tool nuget:?package=NonInvasiveKeyboardHookLibrary.Core&version=2.1.0

NonInvasiveKeyboardHook

A C# hotkey manager that uses a low level global hook, but allows registering for specific keys to reduce invasion of user privacy.

Get it on NuGet

https://www.nuget.org/packages/NonInvasiveKeyboardHookLibrary/

Example

var keyboardHookManager = new KeyboardHookManager();
keyboardHookManager.Start();

// Register virtual key code 0x60 = NumPad0
keyboardHookManager.RegisterHotkey(0x60, () =>
{
    Debug.WriteLine("NumPad0 detected");
});

// Modifiers are supported too
keyboardHookManager.RegisterHotkey(NonInvasiveKeyboardHookLibrary.ModifierKeys.Control, 0x60, () => 
{ 
    Debug.WriteLine("Ctrl+NumPad0 detected");
});

// Multiple modifiers can be specified using the bitwise OR operation
keyboardHookManager.RegisterHotkey(NonInvasiveKeyboardHookLibrary.ModifierKeys.Control | NonInvasiveKeyboardHookLibrary.ModifierKeys.Alt, 0x60, () => 
{ 
    Debug.WriteLine("Ctrl+Alt+NumPad0 detected");
});

// Or as an array of modifiers
keyboardHookManager.RegisterHotkey(new[]{NonInvasiveKeyboardHookLibrary.ModifierKeys.Control, NonInvasiveKeyboardHookLibrary.ModifierKeys.Alt}, 0x60, () =>
{
    Debug.WriteLine("Ctrl+Alt+NumPad0 detected");
});

Sample App

I created a GUI C# app to help test this library: https://github.com/kfirprods/ShortcutHotkeysExample If the examples above did not answer your questions, take a look at the source code of the sample app 😃 Keyboard Shortcuts In-App Screenshot

Read more about Global Hotkeys within Windows applications

For a thorough explanation, look at the CodeProject article: https://www.codeproject.com/Articles/1273010/Global-Hotkeys-within-Desktop-Applications

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 1,089 12/8/2020