#window #event #hook #unhook-win-event #set-win-event-hook

wineventhook

A rusty wrapper over SetWinEventHook and UnhookWinEvent

11 releases (breaking)

0.9.0 Feb 6, 2024
0.8.0 Jun 7, 2023
0.7.0 Jan 18, 2023
0.6.0 Dec 9, 2022
0.2.1 Mar 11, 2022

#48 in Windows APIs

Download history 18/week @ 2023-10-31 22/week @ 2023-11-07 11/week @ 2023-11-14 25/week @ 2023-11-21 36/week @ 2023-11-28 19/week @ 2023-12-05 10/week @ 2023-12-12 21/week @ 2023-12-19 26/week @ 2023-12-26 22/week @ 2024-01-02 14/week @ 2024-01-09 9/week @ 2024-01-16 19/week @ 2024-01-23 23/week @ 2024-01-30 40/week @ 2024-02-06 82/week @ 2024-02-13

164 downloads per month
Used in battery-savior

MIT license

60KB
887 lines

wineventhook

CI crates.io Documentation dependency status MIT

A rusty wrapper over SetWinEventHook and UnhookWinEvent.

Example

This example shows how to listen for all window events and print them to the console.

use wineventhook::{EventFilter, WindowEventHook};

#[tokio::main]
async fn main() {
    // Create a new hook
    let (event_tx, mut event_rx) = tokio::sync::mpsc::unbounded_channel();
    let hook = WindowEventHook::hook(
        EventFilter::default(),
        event_tx,
    ).await.unwrap();
    
    // Wait and print events
    while let Some(event) = event_rx.recv().await {
        println!("{:#?}", event);
    }
    
    // Unhook the hook
    hook.unhook().await.unwrap();
}

License

Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)

Dependencies

~2.5–4MB
~70K SLoC