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

wineventhook

A rusty wrapper over SetWinEventHook and UnhookWinEvent

7 releases (4 breaking)

Uses new Rust 2021

0.5.0 Jul 19, 2022
0.4.0 Jun 25, 2022
0.3.0 Jun 21, 2022
0.2.2 Apr 29, 2022
0.1.0 Mar 3, 2022

#41 in Windows APIs

Download history 31/week @ 2022-04-24 37/week @ 2022-05-01 33/week @ 2022-05-08 70/week @ 2022-05-15 19/week @ 2022-05-22 29/week @ 2022-05-29 22/week @ 2022-06-05 2/week @ 2022-06-12 44/week @ 2022-06-19 15/week @ 2022-06-26 4/week @ 2022-07-03 6/week @ 2022-07-10 31/week @ 2022-07-17 30/week @ 2022-07-24 21/week @ 2022-07-31 8/week @ 2022-08-07

90 downloads per month
Used in battery-savior

MIT license

59KB
881 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.2–3MB
~48K SLoC