wineventhook

Crates.io Documentation MIT licensed Build Status

A safe Rust API for using SetWinEventHook, powered by the windows crate.

Usage

To use win_event_hook, add the following to your Cargo.toml:

toml [dependencies] win_event_hook = "0.1"

Then create a configuration and install a hook, for example:

```rust use wineventhook::events::{Event, NamedEvent};

// create our hook config let config = wineventhook::Config::builder() .skipownprocess() .withdedicatedthread() .with_events(vec![ // to see these, try right clicking Event::Named(NamedEvent::ObjectShow), Event::Named(NamedEvent::ObjectHide), // to see this, try moving around the cursor Event::Named(NamedEvent::ObjectLocationChange), ]) .finish();

// and our handler let handler = |ev, _, _, _, _, _| { println!("got event: {:?}", ev); };

// install the hook let hook = wineventhook::WinEventHook::install(config, handler)?; ```

When hook is dropped, an uninstall is attempted automatically. Uninstallation may fail - to handle failures, instead call uninstall yourself, for example:

```rust // building on the above example

// uninstall the hook hook.uninstall()?; ```

For more information, see the generated documentation.

LICENSE

This project is licensed under the MIT license.