UIAutomation不会检索元素的子级 [英] UIAutomation won't retrieve children of an element

查看:335
本文介绍了UIAutomation不会检索元素的子级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以看到具有特定Automation ID的元素在检查工具中具有子元素:

I can see that an element with specific Automation ID has children in the Inspect tool:

但是当我尝试像这样检索它们时:

But when I try to retrieve them like this:

AutomationElement aPane = mainWindow.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.AutomationIdProperty, "8264"));
AutomationElementCollection theChildren = aPane.FindAll(TreeScope.Subtree, Condition.TrueCondition);

aPane元素已正确检索,但theChildren元素为空.任何想法出了什么问题吗?

The aPane element is retrieved correctly, but theChildren element is empty. Any ideas what went wrong?

推荐答案

实际上,问题在于Inspect.exe是用 托管 代码.非托管代码返回的结果与托管版本返回的结果略有不同(例如,托管代码返回的控制类型为编辑在我的应用中).

Actually the problem is that Inspect.exe is written in unmanaged code while I was trying to achieve the same results in managed code. Unmanaged code returns slightly different results than the managed version (e. g. manged code would return control type document where the unmanaged code would return edit in my application).

虽然花了我一些时间来理解它,但非托管代码却更快,更准确,因此更可靠.

While it took me some time to understand it, unmanaged code is much faster, more accurate and therefore more reliable.

可以在Microsoft Windows UI自动化博客e中找到一些C#的非托管UI自动化代码示例. G.

Some examples of unmanaged UI automation code for C# can be found in the Microsoft Windows UI Automation Blog e. g. here,

这篇关于UIAutomation不会检索元素的子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆