Docs

RunMacro Documentation

Create your first robot, then go further as needed.

Clear step-by-step guides to create, run, and improve robots for repetitive computer work.

Docs Keyboard Smart Get Text
📋 Keyboard

Extract Desktop UI Element Text into Variables (Smart Get Text) in RunMacro

Smart Get Text extracts text directly from desktop UI controls (TextBoxes, Labels, Buttons) into variables via Windows UI Automation without clipboard copying.

Prerequisites#

  • The target desktop application displaying the text or input field is open on screen.
  • The target text element has been picked successfully.

Supported modes#

  • Desktop Mode — Accesses text via UIA ValuePattern, TextPattern, or Name properties.

What it does#

The Smart Get Text command retrieves text strings directly from desktop UI controls (TextBoxes, Labels, TextBlocks, ComboBoxes, StatusBars, or Buttons) via Microsoft UI Automation patterns: ValuePattern.Value, TextPattern, or AutomationElement.CurrentName. It accesses data in memory without needing cursor selection or Ctrl+C keystrokes, and includes built-in Regex Pattern filtering and automatic whitespace trimming.

Screenshots & video#

RunMacro Smart Get Text command configuration dialog showing parameter fields
Configuration dialog and parameter fields for the Smart Get Text command in RunMacro.

When to use it#

  • Capturing newly generated invoice or contract numbers after completing transactions in enterprise apps.
  • Reading account balances or payment totals to feed conditional logic (IF) branches.
  • Extracting error messages or dialog warnings to record into logs or dispatch Telegram alerts.
  • Grabbing customer tax IDs and names from desktop CRM screens into variables for cross-app automation.

When not to use it#

  • Web browser pages (use Smart HTML DOM text commands).
  • Scanned raster text inside remote desktop sessions (use Scan OCR).

Configuration steps#

  1. In RunMacro, select the Keyboard › Smart Get Text command.
  2. Click 🎯 Pick Element and hover over the target label, text box, or status control to capture.
  3. Specify the variable name in Result Variable (e.g. order_id).
  4. Optionally provide a regex in Regex Pattern to isolate numbers or codes (e.g. \d+).
  5. Ensure Trim whitespace is checked.
  6. Select Save to: variable or file.
  7. Click Save to insert the command into the workflow.

Every option explained#

🎯 Pick Element#

Interactive target picker to capture target element UIA identification properties.

Result Variable#

Identifier of the variable where the extracted string is stored (referenced downstream as {var_name}).

Regex Pattern#

Regular expression pattern to filter or isolate substrings (e.g. INV-\d+). Leave empty to retain full text.

Trim whitespace#

Automatically strips leading and trailing spaces and line breaks from the captured text.

Timeout (ms)#

Maximum time to wait for the element to materialize and expose text data (default 3000ms).

Expected result#

The control's text content is accurately assigned to the target variable or file.

Real example#

Example: Capture invoice total amount and parse digits#

  1. Add a Smart Get Text command.
  2. Pick the label showing 'Total: $1,500.00 USD'.
  3. Set Result Variable to total_amount.
  4. Enter Regex Pattern as [0-9\.,]+ to strip currency words.
  5. Variable {total_amount} now cleanly holds 1,500.00.

Limitations and failure cases#

  • Non-standard custom controls that omit Name and Value attributes may return empty strings.
  • Controls completely excluded from the UIA tree require Scan OCR.

Tips & common mistakes#

Smart Get Text can even read masked input values if the underlying application exposes its value attribute via UIA.
For multi-row tables and DataGrids, use Smart Export Table rather than Smart Get Text to preserve column structures.

Verification details#

  • commands/smart_desktop_get_text.py · verified 2026-09-30
RunMacro robot

Robots do the work. Your time is yours.

Create a robot in minutes, no coding needed. Reliable execution, remote management, transparent costs — and you always stay in control.