Skip to content

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.

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.

attributeReturnsType
enabledWhether the control is enabled.bool
visibleWhether the control is inside the visible area (not scrolled out of view).bool
valueThe control’s value (UIA Value pattern); if it has none, its name.string
nameThe control’s name (its text or accessible label).string
checkedWhether the checkbox is checked. null if the control is not a checkbox (no Toggle support).bool
selectedWhether the item is selected (in lists, tabs, radio buttons). null if the control doesn’t support selection.bool
existsWhether the element exists. It doesn’t fail: it returns false if it doesn’t appear within timeout.bool
boundsPosition 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.

ParameterTypeDefaultDescription
selectorselector—The element to query.
attributestring—Property to get: enabled · visible · value · name · checked · selected · exists · bounds (see table).
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. With exists, it’s how long it takes to answer false: use 0 for an immediate check.

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(...).

MessageCause 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.

Act only if the button is enabled:

Win Get Attribute selector = (button "Process") attribute = enabled → output: isEnabled
If condition = toBoolean(isEnabled)
└─ then:
Win Click selector = (button "Process")

Read a control’s position:

Win Get Attribute selector = (panel "Preview") attribute = bounds → output: area
Log message = "Panel at " + area.X + "," + area.Y + ", size " + area.Width + "x" + area.Height