use computeruse::{AutomationError, Desktop};
use tracing::info;
use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() -> Result<(), AutomationError> {
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
)
.init();
let app_name = "Calculator";
info!("Starting accessibility tree print for app: {}", app_name);
let desktop = Desktop::new(false, true)?;
let app = desktop.application(app_name)?;
let max_depth = 20;
let tree = app.to_serializable_tree(max_depth);
match serde_json::to_string_pretty(&tree) {
Ok(json_str) => println!("{json_str}"),
Err(e) => eprintln!("Failed to serialize tree to JSON: {e}"),
}
Ok(())
}