Element state
Passes when an Element found by a locator exists, is enabled or disabled, is on, off or mixed, or is marked.
Element locator is state
Keyboard Maestro: Button, Menu
Details #
Finds an Element with the locator and checks the state you ask for. Where Element exists only tells you the Element is there, this one also checks its state: a button is enabled, a checkbox is ticked, a menu item has a check mark.
The states:
exists: the locator found something.enabled,disabled: found, and its enabled flag is on or off.on,off,mixed: found, and its value is1ortrue(on),0,falseor empty (off), or2(mixed). Checkboxes, radio buttons and switches report these values.marked,unmarked: found, and a menu item has or hasn't a check mark.
Every state except exists is false when nothing is found. That includes disabled, off and unmarked, so a missing element isn't "off"; negate exists to test for absence.
The trace shows found, enabled, value, marked and the state you asked for.
Every condition accepts "negate": true, which flips the verdict. The trace records what was compared before the flip, so a negated condition that blocks a macro still shows the real values.
Conditions in an Only if list combine with all: every one must pass, and an empty list always passes. An if step or a repeat loop takes a match of all (default) or any.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
locator | locator | Yes | A locator object; role is required. Record one with the picker rather than typing it by hand. | |
state | one of | Yes | exists enabled disabled on off mixed marked unmarked | One of exists, enabled, disabled, on, off, mixed, marked, unmarked. |
sample | yes / no | Used only in a dry run: the pretend answer. Default true. |
Examples #
- If Save button is enabled
- Show “Save is enabled”
- Else
- Show “Save is disabled or missing”
Save button
Gotchas #
In a dry run nothing is read: the condition passes with
sample(defaulttrue) and the trace sayssimulated.A locator that is missing or can't be read fails with
elementState needs a locator.