vscode_click_on_search/
vscode_click_on_search.rs

1// Copyright (C) 2024 Tristan Gerritsen <tristan@thewoosh.org>
2// All Rights Reserved.
3
4use ui_automation::{Element, Role, UIAutomation};
5
6fn main() {
7    let ui = UIAutomation::new();
8
9    for app in ui.applications() {
10        println!("App {} {:?}", app.name(), app.owner().pid());
11        if app.name() == "Code" {
12            for window in app.windows() {
13                print_element(window, 0);
14            }
15        }
16    }
17}
18
19fn print_element(element: Element, depth: usize) {
20    let indent = " ".repeat(depth * 2);
21    println!("{indent}{:?} title={} description={} @ {}", element.role(), element.title(), element.description(), element.position());
22
23    if element.role() == Role::RadioButton && element.title().starts_with("Search") {
24        element.click();
25    }
26
27    for child in element.children() {
28        print_element(child, depth + 1);
29    }
30}