简体   繁体   中英

WPF UI Automation finding image

Hey all i am trying to get an image from a WPF application:

在此处输入图片说明

As you can see the image is under the tree

"Remote phone" window > "" custom > "" image

I've found examples of how to find a textbox and button (and also invoking the button) but i have not yet found code that will allow me to get an image and display it within my form picturebox.

LogMessage("Getting RootElement...");
AutomationElement rootElement = AutomationElement.RootElement;

if (rootElement != null)
{
    LogMessage("OK." + Environment.NewLine);

    Automation.Condition condition = new PropertyCondition(AutomationElement.NameProperty, "Remote phone");

    LogMessage("Searching for Remote Phone Window...");
    AutomationElement appElement = rootElement.FindFirst(TreeScope.Children, condition);

    if (appElement != null)
    {
        LogMessage("OK " + Environment.NewLine);
        LogMessage("Searching for Image...");

        AutomationElement txtElementA = GetTextElement(appElement, "image");

        if (txtElementA != null)
          etc..etc...

It finds the appElement just fine but once it gets to the txtElementA it's NULL which it should be since its looking for a GetTextElement instead of a picture/image element.

What would be the proper code in finding the image and grabbing it and then displaying it within a picturebox on my form?

Thanks!

There is no UI Automation pattern that supports what you're trying to do. If you look at your inspect window, you'll notice that all of the IsXXXPatternAvailable properties are false, which means that none of the patterns are available (except for IsLegacyIAccessblePatternAvailable, but that doesn't help you either).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM