Using UIAutomation - GetCachedParent RRS feed

  • Question

  • 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.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.



    Wednesday, November 25, 2020 10:22 AM

All replies

  • Hi Eran Broder,

    Thank you for posting here.

    I note that you are using 'UIAComWrapper' nuget package for which we don't provide help, and you can consider posting your question in the related forum for more efficient responses.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

    Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).

    • Proposed as answer by KHURRAM RAHIM Thursday, November 26, 2020 12:11 PM
    Thursday, November 26, 2020 6:48 AM