Win Get Text
Win Get Text
Section titled “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.
How it works
Section titled “How it works”It locates the element by its selector (waiting up to timeout) and returns, in this order, the first thing the control offers:
- Its value (UIA Value pattern): the content of a text field or a combo box.
- Its full text (UIA Text pattern): the content of a document or rich text area.
- 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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The element whose text to read. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanDesktopSession | — | Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window. |
timeout | number | 30000 | Maximum ms to wait for the element. Empty = the project’s UI timeout or, if not set, 30000. |
Output
Section titled “Output”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.
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”Win Get Text selector = (label "Current balance") → output: balanceTextSet Variable name = balance value = parseDouble(replace(replace(balanceText, "$", ""), ",", ""))Related activities
Section titled “Related activities”- Win Get Attribute — read a specific property (enabled, checked…).
- Win Extract Table — read a whole table at once.