Hi guys.
I am using the IUIAutomation library (COM version) via C#, to analyze Microsoft-Word UI structure.
No matter what I try, I am unable to perform a cache request that has a GetCachedParent
which does not return null.
here is a small standalone sample:
private void TestFunc()
{
CUIAutomationClass Core = new CUIAutomationClass();
var mainWindowElement = Core.ElementFromHandle(Process.GetProcessesByName("WINWORD").First().MainWindowHandle);
var request = Core.CreateCacheRequest();
request.AddProperty(UIA_PropertyIds.UIA_NamePropertyId);
request.TreeScope = TreeScope.TreeScope_Subtree;
var allTreeElements = mainWindowElement.FindAllBuildCache(TreeScope.TreeScope_Subtree, Core.RawViewCondition, request);
var foundCachedParent = false;
for (int i = 0; i < allTreeElements.Length; i++)
{
foundCachedParent = foundCachedParent || allTreeElements.GetElement(i).GetCachedParent() != null;
}
MessageBox.Show("Any parents? " + foundCachedParent);
}
what am I missing?
I have tried various TreeScope alternatives, to not avail.
thanks,
Eran