Skip to content

🔤 A small C# (.NET) Library which allows binding of global HotKeys to any Application's Windows (including Windows Apps such as explorer.exe), even in Background. (using P/Invokes)

License

Notifications You must be signed in to change notification settings

mrousavy/Hotkeys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hotkeys

A small C# (.NET) Library which allows binding of global HotKeys to any Application's Windows (including Windows Apps such as explorer.exe), even in Background. (using P/Invokes)

Install

Install from NuGet

Install-Package GlobalHotkeys

NuGet

(or download the Library (.dll) manually)

Buy Me a Coffee at ko-fi.com

Usage

Example (C#, in a WPF Application):

using mrousavy;
// ...
var key = new HotKey(
    (ModifierKeys.Control | ModifierKeys.Alt), 
    Key.S, 
    this, 
    (hotkey) => {
        MessageBox.Show("Ctrl + Alt + S was pressed!");
    }
);
// ...
key.Dispose();

Note #1: Since HotKey implements the IDisposable interface, you must call Dispose() to unregister the Hotkey, e.g. when your Window closes. Keep in mind that when you're using using(...) { ... }, the HotKey gets unregistered and disposed once you exit the using-statement's scope.

Note #2: Use the binary or operator (|) to combine key combinations for the constructor.

Note #3: Use a Window Reference as the third Argument. This may be a WPF Window, a WindowInteropHelper, or a Window Handle (IntPtr). So you can use your own WPF/WinForms Window, as well as another process's Window using it's Handle. Keep in mind that this is sketchy behaviour and not the intention of this library.

About

🔤 A small C# (.NET) Library which allows binding of global HotKeys to any Application's Windows (including Windows Apps such as explorer.exe), even in Background. (using P/Invokes)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages