use autoitx::{AutoIt, recipes};
use std::time::{Duration, Instant};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ai = AutoIt::new()?;
println!("waiting for the frontmost application to be ready...");
let started = Instant::now();
match recipes::wait_until_idle(&ai, Duration::from_secs(10)) {
Ok(()) => println!("ready after {:?}", started.elapsed()),
Err(e) => println!("still busy after {:?}: {e}", started.elapsed()),
}
#[cfg(target_os = "macos")]
{
println!("\nmacOS can also ask about one process by pid:");
let me = std::process::id() as i32;
println!(
" is_app_responsive({me}) = {}",
autoitx::ext::macos::is_app_responsive(me, Duration::from_millis(500))
);
}
#[cfg(windows)]
{
println!("\nWindows can also read the raw cursor shape:");
println!(" mouse_get_cursor() = {:?}", ai.mouse_get_cursor()?);
}
Ok(())
}