IUIAutomationTextPattern::GetVisibleRanges method

Retrieves an array of disjoint text ranges from a text-based control where each text range represents a contiguous span of visible text.


HRESULT GetVisibleRanges(
  [out, retval] IUIAutomationTextRangeArray **ranges


ranges [out, retval]

Type: IUIAutomationTextRangeArray**

Receives a pointer to the collection of visible text ranges within the text-based control.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


If the visible text consists of one contiguous span of text, the ranges array will contain a single text range that represents all of the visible text.

If the visible text consists of multiple, disjoint spans of text, the ranges array will contain one text range for each visible span, beginning with the first visible span, and ending with the last visible span. Disjoint spans of visible text can occur when the content of a text-based control is partially obscured by an overlapping window or other object, or when a text-based control with multiple pages or columns has content that is partially scrolled out of view.

IUIAutomationTextPattern::GetVisibleRanges retrieves a degenerate (empty) text range if no text is visible, if all text is scrolled out of view, or if the text-based control contains no text.


Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista, Windows XP with SP3 and Platform Update for Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008, Windows Server 2003 with SP2 and Platform Update for Windows Server 2008 [desktop apps only]


UIAutomationClient.h (include UIAutomation.h)



See also

UI Automation Support for Textual Content