Share via


IUIAutomation::GetRootElement Method

Retrieves the UI Automation element that represents the desktop.

Syntax

HRESULT GetRootElement(      
    IUIAutomationElement **root
);

Parameters

  • 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::GetRootElementBuildCache