use autoitx::options::{KeyMap, Options};
use autoitx::{AutoIt, keys, recipes};
use std::time::Duration;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ai = AutoIt::builder()
.options(Options::default().with_key_map(KeyMap::PortableShortcuts))
.build()?;
println!("Focus a text editor. Reading its contents in 4 seconds...\n");
std::thread::sleep(Duration::from_secs(4));
println!(
"active window: {:?}",
ai.win_get_title(&autoitx::Selector::active())?
);
match recipes::read_screen_text(&ai, keys!("{CTRLDOWN}a{CTRLUP}"), Duration::from_secs(5)) {
Ok(text) => {
println!("\nread back {} characters:", text.chars().count());
println!("{:?}", text.chars().take(200).collect::<String>());
}
Err(e) => {
println!("\nnothing reached the clipboard: {e}");
}
}
Ok(())
}