A WPF Application is using an Application Framework and I can edit neither of them.
I can visit every element in the GUI doing something along these lines:
IUIItem[] items = window.GetMultiple(SearchCriteria.All);
foreach (var item in items)
{
visit((dynamic)item);
}
I have no Issue with normal controls but I hit a wall with CustomUIItem
.
I would like to visit all the Children of it but I fail to make a new array IUIItem[]
from them.
Here is what I have now:
void visit(CustomUIItem item)
{
AutomationElementCollection children =
item
.AutomationElement
.FindAll(TreeScope.Children, Condition.TrueCondition);
UIItemCollection temp = new UIItemCollection(children.Cast<AutomationElement>());
foreach(var t in temp)
{
visit((dynamic)t);
}
}
Somethimes this throws and most of the time collection remains empty.
The CusomControl
has "normal" controls among its children.
I want those as regular IUIItem
s.
Where can I find the documentation for this. The only thing I found was this, and I can not do that since I am only visiting from outside and I do not know the controls content.