Share via


IUIAutomation::GetFocusedElement Method

Retrieves the UI Automation element that has the input focus.

Syntax

HRESULT GetFocusedElement(      
    IUIAutomationElement **element
);

Parameters

  • element
    [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

The IUIAutomation::GetFocusedElement method returns the UIA_E_ELEMENTNOTAVAILABLE error code if the focused element is already removed by the time the method returns. Clients should handle errors from this method gracefully; for example, by trying the call again.