use computeruse::Desktop;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("๐งช Testing UWP window maximize...\n");
let desktop = Desktop::new(false, true)?; println!("โ
Desktop initialized");
println!("๐ฑ Opening Calculator...");
let ui_element = desktop.open_application("Calculator")?;
println!("โ
Calculator opened");
let pid = ui_element.process_id().unwrap_or(0);
let window_title = ui_element.window_title();
println!(" PID: {pid}");
println!(" Window: {window_title}");
if let Ok((x, y, width, height)) = ui_element.bounds() {
println!("\n๐ Initial bounds:");
println!(" x: {x}, y: {y}, width: {width}, height: {height}");
}
println!("\n๐ Attempting to maximize via UI Automation...");
match ui_element.maximize_window() {
Ok(_) => {
println!("โ
maximize_window() call succeeded");
}
Err(e) => {
println!("โ maximize_window() failed: {e}");
return Err(e.into());
}
}
std::thread::sleep(std::time::Duration::from_millis(500));
if let Ok((x, y, width, height)) = ui_element.bounds() {
println!("\n๐ Final bounds:");
println!(" x: {x}, y: {y}, width: {width}, height: {height}");
}
println!("\nโจ Test complete! Check if Calculator is maximized.");
Ok(())
}