[英]WPF UI Automation finding image
嘿,我正在尝试从WPF应用程序获取图像:
如您所见,图像在树下
“远程电话”窗口>“”自定义>“”图像
我已经找到了有关如何查找文本框和按钮(以及调用按钮)的示例,但是我还没有找到允许我获取图像并将其显示在表单图片框内的代码。
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...
它发现appElement很好,但是一旦到达txtElementA ,它应该为NULL ,因为它正在寻找GetTextElement而不是图片/图像元素。
查找图像并抓取图像,然后将其显示在表单上的图片框内,正确的代码是什么?
谢谢!
没有UI自动化模式可以支持您尝试执行的操作。 如果查看检查窗口,则会注意到所有IsXXXPatternAvailable
属性均为false,这意味着所有模式均不可用(IsLegacyIAccessblePatternAvailable除外,但这也无济于事)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.