简体   繁体   English

Windows UI Automation不显示所有子元素?

[英]Windows UI Automation not showing all child elements?

I have a TreeView control on my form, and I'm recursively going through the elements of another window starting with the window itself. 我的表单上有一个TreeView控件,我以递归方式从窗口本身开始浏览另一个窗口的元素。 I'm using this to find the elements: 我用这个来找到元素:

getRecursiveElements(AutomationElement parent)
{
  children = parent.FindAll(TreeScope.Children, Condition.TrueCondition);

  foreach (AutomationElement child in children)
  {
    addToTreeView(child);
    getRecursiveElements(child);
  }
}

Generally speaking, the code works quite well in most cases. 一般来说,代码在大多数情况下都能很好地工作。 The tree is populated and I have a bit of other supporting code allowing me to double click, for example, an element in the tree-view and it will highlight that element on the target form. 树被填充,我有一些其他支持代码,允许我双击,例如,树视图中的元素,它将突出显示目标表单上的元素。

The issue I'm having is that, while it generates an awesome tree, there are still some elements missing for certain target programs. 我遇到的问题是,虽然它生成了一个很棒的树,但某些目标程序仍然缺少一些元素。

What possible reason could there be for this, and is there any way to get around it? 可能有什么理由可以解决这个问题,有什么方法可以解决这个问题吗? If I call EnumChildWindows() from user32.dll will that have the same problem? 如果我从user32.dll调用EnumChildWindows()会有同样的问题吗?

Not all programs use separate windowed controls for all their logical children. 并非所有程序都为其所有逻辑子项使用单独的窗口控件。 Mostly this depends on the GUI framework used. 这主要取决于所使用的GUI框架。

As an extreme example, Qt uses a single window for each top-level window. 作为一个极端的例子,Qt为每个顶级窗口使用一个窗口。 It then paints all the widgets on the form from the form's WM_PAINT message handler. 然后它从表单的WM_PAINT消息处理程序中绘制表单上的所有小部件。

Programs that take this approach are typically impossible to automate through generic methods. 采用这种方法的程序通常不可能通过通用方法自动化。

It sounds like you have encountered an application that uses some windowed controls but also uses custom controls with a single window for what appears to be multiple widgets. 听起来您遇到了一个使用某些窗口控件的应用程序,但也使用带有单个窗口的自定义控件来显示多个窗口小部件。 Again this is quite common. 这又是很常见的。

Could you give a better example of what fails? 你能举一个更好的例子吗? Thinking about the problem, it may be that the 'element' in the other form is being drawn manually, and so doesn't have distinct registered handles for everything. 考虑到这个问题,可能是其他形式的“元素”是手动绘制的,因此没有针对所有内容的不同注册句柄。

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

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