GlobalHotkeysRX 1.1.0
See the version list below for details.
dotnet add package GlobalHotkeysRX --version 1.1.0
NuGet\Install-Package GlobalHotkeysRX -Version 1.1.0
<PackageReference Include="GlobalHotkeysRX" Version="1.1.0" />
paket add GlobalHotkeysRX --version 1.1.0
#r "nuget: GlobalHotkeysRX, 1.1.0"
// Install GlobalHotkeysRX as a Cake Addin #addin nuget:?package=GlobalHotkeysRX&version=1.1.0 // Install GlobalHotkeysRX as a Cake Tool #tool nuget:?package=GlobalHotkeysRX&version=1.1.0
GlobalHotKeysRX
A small C# WPF library to create global keyboard shortcuts. With this library, you can implement keyboard shortcuts to perform specific actions in your applications, regardless of the active window. Works globally, allowing the activation of shortcuts on any window.
*No Window is required, so you can use it in background/windowless applications.
Supports combinations of:
-Modifier keys: Alt, Control, Shift, Win (Up to 3 at the same time)
-WPF Keys, listed at System.Windows.Input Key Enum.
Usage
import
using GlobalHotKeysRX;
initialization
Combo combo1 = new Combo(Modifiers.Alt, Key.C); //dual combo (alt + C)
Combo combo2 = new Combo(Modifiers.Alt | Modifiers.Control, Key.Z); //triple combo (Alt + Control + Z)
HotKeys hks = new HotKeys();
Use the | operator to combine/add modifiers.
By using 'Modifiers.NoRepeat' with another modifier, the application will only receive another WM_HOTKEY message when the key is released and then pressed again while a modifier is held down.
adding a hotkey
hks.AddMethod(combo1, myfunction);
void myfunction()
{
//code when a hotkey occurs...
}
removing
hks.DeleteMethod(combo1); //single
hks.ClearAll(); //all
cleaning up resources
hks.Dispose();
pause/play
hks.Pause(combo1); //don´t call the Action
//...
hks.Play(combo1); //calls back the Action
simplest way
HotKeys hks = new HotKeys(new Combo(Modifiers.Control, Key.Q), () => { /*code...*/ });
Known issues
This library uses Win32 API. Typically, RegisterHotKey fails if the keystrokes specified for the hot key have already been registered for another hot key. However, some pre-existing, default hotkeys registered by the OS (such as PrintScreen, which launches the Snipping tool) may be overridden by another hot key registration when one of the app's windows is in the foreground.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-windows7.0 is compatible. |
-
net8.0-windows7.0
- 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.