Based on this post, I am trying to convert my code from using the managed c# uiautomation over to using the UIAManaged wrapper generated by the tlbimp.exe SDK tool (see post linked above for information how to do that.
I'm trying to use the UIAManaged wrapper to try and get some performance gains in my application.
Right now, I have a method that looks something like this:
public void CacheAndPrintNames(AutomationElement element)
{
var request = new CacheRequest
{
AutomationElementMode = AutomationElementMode.None,
TreeFilter = Automation.RawViewCondition,
TreeScope = TreeScope.Subtree
};
request.Add(AutomationElement.NameProperty);
AutomationElementCollection children = null;
using (request.Activate())
{
children = element.FindAll(
TreeScope.Descendants,
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text)
);
}
foreach (AutomationElement child in children)
{
if (child != element && !String.IsNullOrWhiteSpace(child.Cached.Name))
{
log(child.Current.Name);
}
}
}
What I would like to do is convert the method above to use the UIAManaged wrapper to do the same thing - the goal being compare the two methods and see if I get performance gains by converting to using the different dll.
I've gotten so far, but I can't find the correct way to search (i.e. execute the find all using this new wrapper. -- starting code below)
using Interop.UIAutomationCore;
public void CacheAndPrintNames(AutomationElement element)
{
var uiAutomation = new CUIAutomation();
var request = uiAutomation.CreateCacheRequest();
request.AutomationElementMode = Interop.UIAutomationCore.AutomationElementMode.AutomationElementMode_None;
request.AddProperty(30005); // 30005 is nameProperty
// how do i start the cache request, and execute a FindAll search?
}
Has anyone done something similar? Are there articles/blogposts/SO posts about using this UIAManaged wrapper generated by the tlbimp.exe SDK tool?