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 around 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With