Crates.io | win-hotkey |
lib.rs | win-hotkey |
version | |
source | src |
created_at | 2024-12-01 06:58:58.920163 |
updated_at | 2024-12-18 01:03:12.633551 |
description | A lightweight, thread-safe Rust library for managing system-wide hotkeys on Windows, with high-level abstractions and customizable callbacks. |
homepage | https://github.com/0xJWLabs/win-hotkey |
repository | https://github.com/0xJWLabs/win-hotkey |
max_upload_size | |
id | 1467253 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
win-hotkey
is a lightweight and opinionated Rust crate designed for handling system-wide hotkeys on Windows. It provides an easy-to-use abstraction over the Windows API, enabling thread-safe hotkey registration and callback execution.
Alt + A
)VK_*
) and Modifier Keys (MOD_*
).VirtualKey
) and modifiers keys (ModifiersKey
) from human-readable strings.HotkeyManager
instance.VirtualKey
, one or more ModifiersKey
s, and a callback.use win_hotkey::keys::{ModifiersKey, VirtualKey};
use win_hotkey::{HotkeyManager, HotkeyManagerImpl};
fn main() {
let mut hkm = HotkeyManager::new();
hkm.register(VirtualKey::A, &[ModifiersKey::Alt], || {
println!("Hotkey ALT + A was pressed");
})
.unwrap();
hkm.event_loop();
}
Windows hotkey events must be registered and unregistered on the same thread. This limitation makes traditional multi-threaded hotkey management cumbersome.
win-hotkey
provides two hotkey manager implementations:
single_thread::HotkeyManager
)thread_safe::HotkeyManager
) (Default)With the thread_safe
feature enabled (default), the crate automatically provides the thread-safe implementation.
This project is licensed under the MIT License
See the LICENSE
file for details