Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

GetCachedChildren not working

$
0
0
I am new to UIA and i am having some problem in properly caching my elements. The thing is my GetCachedChildren function always returns a NULL for my children array. And the reason behind it is i think me. Because i am having a hard time understanding which of the elements get cached or how to properly cache them.

IUIAutomationCacheRequest* CacheRequest = NULL;
        hr = Auto->CreateCacheRequest(&CacheRequest);
        if (SUCCEEDED(hr))
        {
            hr = CacheRequest->AddProperty(UIA_BoundingRectanglePropertyId);
            if (SUCCEEDED(hr))
            {
                hr = CacheRequest->AddProperty(UIA_NamePropertyId);
                if (SUCCEEDED(hr))
                {
                    hr = CacheRequest->AddProperty(UIA_LocalizedControlTypePropertyId);
                    if (SUCCEEDED(hr))
                    {
                        hr = CacheRequest->AddPattern(UIA_ButtonControlTypeId);
                    }
                }
            }
        }

        IUIAutomationCondition* ButtonCon = NULL;
        IUIAutomationElementArray* ButtonArray = NULL;
        IUIAutomationElement* Button = NULL;
        VARIANT var;
        var.vt = VT_I4;
        var.lVal = UIA_ButtonControlTypeId;
        Auto->CreatePropertyCondition(UIA_ControlTypePropertyId, var, &ButtonCon);
        if (ButtonCon == NULL)
        {
            return;
        }

        Parent->FindAllBuildCache(TreeScope_Children, ButtonCon, CacheRequest, &ButtonArray);

In the next iteration when i call
Parent->GetCachedChildren(&Element);
 It doesnt work.


Now i am not sure how to retrieve these cached elements? whenever i try to get elements via getcachedchildren the array is always empty? Can someone at least give me an idea (theoretically) as to how to properly cache the elements? Because i am finding it really hard to understand what the sequence of my actions will be in order to peroperly cache and retrieve the elements and their properties.

Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>