Share via


IUIAutomation::GetRootElementBuildCache Method

Retrieves the UI Automation element that represents the desktop, prefetches the requested properties and control patterns, and stores the prefetched items in the cache.

Syntax

HRESULT GetRootElementBuildCache(      
    IUIAutomationCacheRequest *cacheRequest,
    IUIAutomationElement **root
);

Parameters

  • cacheRequest
    [in] The address of the IUIAutomationCacheRequest interface of cache request, which specifies the properties and control patterns to store in the cache.
  • root
    [out, retval] The address of a variable that receives a pointer to the IUIAutomationElement interface.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

You can use the root element as a starting point for finding other elements, using the IUIAutomationElement::FindAll and IUIAutomationElement::FindFirst methods.

When searching from the root element, be sure to specify TreeScope_Children in the scope of the search, not TreeScope_Descendants. A search through the entire subtree of the desktop could iterate through thousands of items and lead to a stack overflow.

See Also

IUIAutomation::GetRootElement