GlobalHotkeysRX 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GlobalHotkeysRX --version 1.0.0                
NuGet\Install-Package GlobalHotkeysRX -Version 1.0.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="GlobalHotkeysRX" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GlobalHotkeysRX --version 1.0.0                
#r "nuget: GlobalHotkeysRX, 1.0.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 GlobalHotkeysRX as a Cake Addin
#addin nuget:?package=GlobalHotkeysRX&version=1.0.0

// Install GlobalHotkeysRX as a Cake Tool
#tool nuget:?package=GlobalHotkeysRX&version=1.0.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();

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 Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last updated
2.0.0 122 10/11/2024
1.1.0 109 8/1/2024
1.0.0 84 7/28/2024