#macos #window #windows

window-observer

The library for observing information about the windows

4 releases

Uses new Rust 2024

new 0.1.3 Nov 4, 2025
0.1.2 Oct 28, 2025
0.1.1 Oct 27, 2025
0.1.0 Oct 27, 2025

#59 in Windows APIs

Download history 222/week @ 2025-10-22 10/week @ 2025-10-29

232 downloads per month

MIT license

56KB
1K SLoC

window-observer-rs

This crate provides an observer that receives events such as window movement and resizing. It is designed to receive window events on Windows and macOS for cross-platform applications.

Crates.io Version docs.rs

Example

use window_observer::{EventFilter, WindowObserver};

#[tokio::main]
async fn main() {
    let pid = std::env::var("PID")
        .map(|v| v.parse().unwrap())
        .expect("Please give me the env `PID` of application that has window.");

    let (event_tx, mut event_rx) = tokio::sync::mpsc::unbounded_channel();
    let event_filter = EventFilter::all();

    let _window_observer = WindowObserver::start(pid, event_tx, event_filter)
        .await
        .unwrap();

    while let Some(event) = event_rx.recv().await {
        match event {
            Ok(event) => println!("new event: {event:#?}"),
            Err(e) => eprintln!("Error occurred during handling event: {e:#?}"),
        }
    }
}

Platform supports

  • macOS*
  • Windows
  • Linux?
    I have no plans to make this at this time due to my inexperienced knowledge about Linux. But I'd be happy to receive pull requests.

* Note that window operations on macOS use the Accessibility API, so accessibility permissions are required.

Acknowledgements

License

This project is licensed under the MIT License.

Dependencies

~4–37MB
~597K SLoC