https://github.com/lexz-08/sharpkey
A library for creating simple and easy to use hotkeys.
https://github.com/lexz-08/sharpkey
csharp hotkeys user32 windows
Last synced: 18 days ago
JSON representation
A library for creating simple and easy to use hotkeys.
- Host: GitHub
- URL: https://github.com/lexz-08/sharpkey
- Owner: Lexz-08
- Created: 2021-02-24T02:04:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-02T01:31:13.000Z (about 5 years ago)
- Last Synced: 2025-01-07T14:25:11.972Z (over 1 year ago)
- Topics: csharp, hotkeys, user32, windows
- Language: C#
- Homepage: https://github.com/Lexz-08/SharpKey/
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## SharpKey
### Description
A library for creating ***simple*** and ***easy to use*** hotkeys.
### How To Use
Now obviously, this is more easily used in an application that uses the `System.Windows.Forms` library because of the WndProc(ref Message m) function.
```csharp
// Assuming you're in the code of a Windows Form.
private Hotkey Hotkey1, Hotkey2;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Initialize 2 new instances of Hotkey.
Hotkey1 = new Hotkey(Handle, 0, FSModifiers.Shift, Keys.C);
Hotkey2 = new Hotkey(Handle, 1, FSModifiers.Shift, Keys.M);
// Register both instances.
// The default value of the Notify parameter is set to TRUE, so you'll
// notice immediately whether or not the registration was a success.
Hotkey1.Hook();
Hotkey2.Hook();
}
protected override void WndProc(ref Message m)
{
if (m.Msg == Hotkey.HOTKEY)
{
int WParam = (int)m.WParam;
if (WParam == Hotkey1.Id) // Close the window if Shift+C is pressed.
Close();
else if (WParam == Hotkey2.Id) // Minimize the window if Shift+M is pressed.
WindowState = FormWindowState.Minimized;
}
base.WndProc(ref m);
}
```
### Download
[SharpKey.dll](https://github.com/Lexz-08/SharpKey/releases/download/sharpkey/SharpKey.dll)