简体   繁体   English

WPF UI自动化查找图像

[英]WPF UI Automation finding image

Hey all i am trying to get an image from a WPF application: 嘿,我正在尝试从WPF应用程序获取图像:

在此处输入图片说明

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. 它发现appElement很好,但是一旦到达txtElementA ,它应该为NULL ,因为它正在寻找GetTextElement而不是图片/图像元素。

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. 没有UI自动化模式可以支持您尝试执行的操作。 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). 如果查看检查窗口,则会注意到所有IsXXXPatternAvailable属性均为false,这意味着所有模式均不可用(IsLegacyIAccessblePatternAvailable除外,但这也无济于事)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有白色问题的UI自动化查找子项 - UI Automation with White issue finding childs UI自动化cmdlet找不到控件 - UI-Automation cmdlet not finding the control 在 WPF 网格中为数据项设置自动化 ID,以使用 UI 自动化框架实现自动化 - Setting automationIDs for dataitems in a WPF Grid for automation with UI Automation Framework Windows UI Automation API在服务器上运行时无法查找子元素 - Windows UI Automation API not finding child elements when run on server WPF控件的UI自动化测试似乎忽略了绑定 - UI automation testing of WPF controls seems to ignore bindings 如何使用DataTemplate刷新WPF AutomationElement-Windows UI Automation - How to refresh WPF AutomationElement with DataTemplate - Windows UI Automation WPF UI自动化-在单击TabControl的区域之前,控制树不会出现问题 - WPF UI Automation - Control Tree not poluated till region is clicked for a TabControl WPF:为UI自动化测试绑定期间生成的命名控件 - WPF: Naming controls generated during binding for UI Automation Tests 在WPF的现代UI中无法显示图像 - Image don't display in Modern UI For WPF 是否可以使用 Microsoft 自动化 UI 在 WPF/WinForm 应用程序上单击标签控件 - Is it possible to Click a label control on WPF/WinForm App using Microsoft Automation UI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM