pause/
pause.rs

1use win_hotkeys::HotkeyManager;
2use win_hotkeys::VKey;
3
4fn main() {
5    let mut hkm = HotkeyManager::new();
6
7    // Register a system-wide hotkey with the trigger key 'A' and the modifier key 'CTRL'
8    let trigger_key = VKey::A;
9    let mod_key = VKey::Control;
10    hkm.register_hotkey(trigger_key, &[mod_key], || {
11        println!("Hotkey CTRL + A was pressed");
12    })
13    .unwrap();
14
15    // Register a system-wide hotkey with the trigger key 'V' and the modifier key 'CTRL'
16    hkm.register_hotkey(VKey::V, &[VKey::Control], || {
17        println!("Hotkey CTRL + V was pressed");
18    })
19    .unwrap();
20
21    // Register pause hotkey. This hotkey will toggle the pause state of win-hotkeys,
22    // allowing only registered pause hotkeys to be processed.
23    let trigger_key = VKey::P;
24    let modifiers = &[VKey::Control, VKey::Shift];
25    hkm.register_pause_hotkey(trigger_key, modifiers, || {
26        println!("Hotkey CTRL + Shift + P toggles pause state for win-hotkeys!");
27    })
28    .unwrap();
29
30    hkm.event_loop();
31}