[英]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.