Skip to content

Win Get Text

Type: win-get-text  ·  Package: Desktop Activities v1.0.8  ·  Output: string

Reads the text or value of an element in a desktop application: a label, a field, a cell. It is the key activity to extract data from an app: a total, a status, a result.

It locates the element by its selector (waiting up to timeout) and returns, in this order, the first thing the control offers:

  1. Its value (UIA Value pattern): the content of a text field or a combo box.
  2. Its full text (UIA Text pattern): the content of a document or rich text area.
  3. Its name: the text of a label, a button or a cell.

In Java applications the text is read through the Swing bridge. It only reads: it doesn’t click or bring the window to the front.

ParameterTypeDefaultDescription
selectorselector—The element whose text to read.
ParameterTypeDefaultDescription
sessionZoanDesktopSession—Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window.
timeoutnumber30000Maximum ms to wait for the element. Empty = the project’s UI timeout or, if not set, 30000.

Returns a string with the element’s text or value, as the application shows it (with its number and date format). If the control has no text, it returns empty (or null); use str(...) to always treat it as text.

MessageCause and fix
Element not found with selector {…}.The element did not appear within timeout. See common errors.
The Java control could not be located unambiguously, so nothing was done. …In a Java app there are several identical controls. Add an anchor or an idx to the selector.
Win Get Text selector = (label "Current balance") → output: balanceText
Set Variable name = balance value = parseDouble(replace(replace(balanceText, "$", ""), ",", ""))