Win Get Attribute
Win Get Attribute
Section titled “Win Get Attribute”Type: win-get-attribute · Package: Desktop Activities v1.0.8 · Output: object
Gets a specific property of an element: whether it is enabled, whether it is visible, its value, its name, whether it is checked, etc. Useful to make decisions based on the state of the interface — check that a button is enabled, whether a checkbox is checked, read a control’s position.
How it works
Section titled “How it works”It locates the element by its selector (waiting up to timeout) and returns the value of the property set in attribute. It only reads: it doesn’t click or bring the window to the front.
Available attributes
Section titled “Available attributes”attribute | Returns | Type |
|---|---|---|
enabled | Whether the control is enabled. | bool |
visible | Whether the control is inside the visible area (not scrolled out of view). | bool |
value | The control’s value (UIA Value pattern); if it has none, its name. | string |
name | The control’s name (its text or accessible label). | string |
checked | Whether the checkbox is checked. null if the control is not a checkbox (no Toggle support). | bool |
selected | Whether the item is selected (in lists, tabs, radio buttons). null if the control doesn’t support selection. | bool |
exists | Whether the element exists. It doesn’t fail: it returns false if it doesn’t appear within timeout. | bool |
bounds | Position and size in screen pixels: a rectangle with X, Y, Width and Height. | object |
In Java applications without Java Access Bridge, name, visible, bounds, value and checked are read through the Swing bridge; enabled and selected are not available that way.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The element to query. |
attribute | string | — | Property to get: enabled · visible · value · name · checked · selected · exists · bounds (see table). |
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. With exists, it’s how long it takes to answer false: use 0 for an immediate check. |
Output
Section titled “Output”Returns an object whose type depends on the attribute (see the table). To use it in a condition, convert it with toBoolean(...); for text, with str(...).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Element not found with selector {…}. | The element did not appear within timeout (with any attribute except exists). See common errors. |
'…' cannot be read from this Java control without Java Access Bridge. | enabled or selected on a Java app without Java Access Bridge enabled. Enable it on the machine or use another attribute. |
Unknown attribute: '…'. | attribute is not one of the eight values in the table. |
Example
Section titled “Example”Act only if the button is enabled:
Win Get Attribute selector = (button "Process") attribute = enabled → output: isEnabledIf condition = toBoolean(isEnabled) └─ then: Win Click selector = (button "Process")Read a control’s position:
Win Get Attribute selector = (panel "Preview") attribute = bounds → output: areaLog message = "Panel at " + area.X + "," + area.Y + ", size " + area.Width + "x" + area.HeightRelated activities
Section titled “Related activities”- Win Get Text — read the text/value directly.
- Win Element Exists — check existence without waiting by default.
- Win Wait For — wait for a state instead of querying it.