Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when using RuntimeId in a property condition #52

Closed
jelder opened this issue Apr 25, 2024 · 2 comments
Closed

Crash when using RuntimeId in a property condition #52

jelder opened this issue Apr 25, 2024 · 2 comments

Comments

@jelder
Copy link
Contributor

jelder commented Apr 25, 2024

I'm working something where I need to discover an element through a walker, and then later interact with it by its RuntimeId. I may be using the API wrong, but the most obvious (to me) way crashes with (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION).

In the below MVBR, for simplicity sake, I'm skipping the walker and just trying to find the root element a second time using the result of root.get_runtime_id().

use uiautomation::core::UIAutomation;
use uiautomation::types::{TreeScope, UIProperty};
use uiautomation::variants::*;

fn main() {
    let automation = UIAutomation::new().unwrap();
    let root = automation.get_root_element().unwrap();
    let runtime_id = root.get_runtime_id().unwrap();

    // exit code: 0xc0000005, STATUS_ACCESS_VIOLATION occurs on next line
    let condition = automation
        .create_property_condition(
            UIProperty::RuntimeId,
            Variant::from(Value::ArrayI4(runtime_id)),
            None,
        )
        .expect("Failed to create condition");

    let element = root
        .find_first(TreeScope::Element, &condition)
        .expect("Failed to find element");

    eprintln!("{}", element.get_name().unwrap());
}
@leexgone
Copy link
Owner

There seems to be a problem handling the conversion of Vec to Variant.
I just need some time to research this problem.

@leexgone
Copy link
Owner

fixed on v0.9.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants