开发者

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. 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 aroun开发者_StackOverflow中文版d it? If I call EnumChildWindows() from user32.dll will that have the same problem?


Not all programs use separate windowed controls for all their logical children. Mostly this depends on the GUI framework used.

As an extreme example, Qt uses a single window for each top-level window. It then paints all the widgets on the form from the form's WM_PAINT message handler.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜