| Crates.io | window-observer |
| lib.rs | window-observer |
| version | 0.1.3 |
| created_at | 2025-10-27 05:50:12.966591+00 |
| updated_at | 2025-11-04 14:58:14.246971+00 |
| description | The library for observing information about the windows. |
| homepage | |
| repository | https://github.com/tasuren/window-observer-rs |
| max_upload_size | |
| id | 1902315 |
| size | 72,414 |
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.
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:#?}"),
}
}
}
* Note that window operations on macOS use the Accessibility API, so accessibility permissions are required.
This project is licensed under the MIT License.