Skip to main content

Text

Return the Control text.

public string Text;

Return Value

The text value of the control, such as the window caption, button text or status bar.

Note that some controls may not have text readable by this method that calls the Win32 API GetWindowText(HANDLE);

Using the AutomationControl Text method may be successful.

Example

Control wind_1 = FindTopWindow("", "WindowsForms10.Window.8.app.0.11c7a8c");
if (wind_1.Text.Contains("SomeText"))
{
....

string myText = myControl.ToAutomationControl.Text // convert to an automation control to read the text.

Related: