use autoitx::{AutoIt, Selector};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ai = AutoIt::new()?;
let window = Selector::active();
let rect = ai.win_get_pos(&window)?;
println!("active window at {rect:?}\n");
for (label, dx, dy) in [("OK button", 600, 420), ("first grid cell", 120, 180)] {
let point = rect.point_at(dx, dy);
println!(" {label:16} offset ({dx}, {dy}) -> screen {point:?}");
}
println!("\nrecipes::click_in_window(&ai, &window, 600, 420) clicks the first");
println!("of those, re-measuring the window immediately before it does — so");
println!("a window that moved between the two calls cannot mislead it.");
println!("\nThe absolute-coordinate equivalent, for comparison:");
println!(
" ai.mouse_click(Point::new({}, {}))",
rect.x + 600,
rect.y + 420
);
println!(" ...which is correct exactly until something moves.");
Ok(())
}