Browse the docs

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 is 1 or true (on), 0, false or empty (off), or 2 (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 #

ParameterTypeRequiredValuesWhat it does
locatorlocatorYesA locator object; role is required. Record one with the picker rather than typing it by hand.
stateone ofYesexists enabled disabled on off mixed marked unmarkedOne of exists, enabled, disabled, on, off, mixed, marked, unmarked.
sampleyes / noUsed only in a dry run: the pretend answer. Default true.

Examples #

Is the Save button enabled
Do
  1. If Save button is enabled
  2. Show “Save is enabled”
  3. Else
  4. Show “Save is disabled or missing”
Open in Switchboard to try it
Where to look

Save button

In Switchboard, Pick an element fills this in for you.

Gotchas #

  • In a dry run nothing is read: the condition passes with sample (default true) and the trace says simulated.

  • A locator that is missing or can't be read fails with elementState needs a locator.

See also #