Overview
Ensures a checkbox or switch is in the unchecked state. If already unchecked, does nothing. This is an idempotent operation, safe to call multiple times.Syntax
Parameters
Element reference from snapshot (must be a
checkbox or switch)Response
Response Fields
The action performed (
uncheck)The element reference that was unchecked
Element state after operation
role(string): “checkbox” or “switch”value(string): “0” (unchecked)states(string[]): Does not include “checked”
AX-First Strategy
The uncheck command:- Reads current state via
kAXValueAttribute - If already unchecked (value = 0), returns success without action
- If checked (value = 1), performs
kAXPressAction - Verifies final state is unchecked
Usage Examples
Uncheck Checkbox
Idempotent Uncheck
Disable Multiple Options
Reset Form State
Uncheck vs Toggle
| Command | Behavior | Idempotent | Use Case |
|---|---|---|---|
uncheck | Ensure unchecked | Yes | Desired end state |
toggle | Flip state | No | Unknown current state |
check | Ensure checked | Yes | Desired end state |
uncheck when:
- You need the checkbox unchecked
- Idempotency is important
- Running automation scripts repeatedly
- Resetting to default state
toggle when:
- You want to flip whatever the current state is
- Simulating user clicking
Supported Element Types
| Role | Uncheck Behavior |
|---|---|
checkbox | Sets to unchecked |
switch | Sets to off |
radiobutton | Cannot uncheck (use different radio) |
State Verification
Error Cases
| Error Code | Cause | Recovery |
|---|---|---|
ELEMENT_NOT_FOUND | Ref doesn’t exist in current refmap | Run snapshot to refresh |
STALE_REF | Element no longer matches saved ref | Run snapshot and use new ref |
ACTION_FAILED | Cannot set unchecked state | Element may be disabled |
ACTION_NOT_SUPPORTED | Element is not a checkbox/switch | Wrong element type |
Common Use Cases
- Reset Settings: Disable settings in preferences
- Forms: Clear form checkboxes
- Permissions: Revoke permissions
- Feature Flags: Disable features
- Cleanup Scripts: Reset application state
Idempotency Benefits
Radio Button Behavior
Radio buttons cannot be truly “unchecked” once selected:Notes
- Uncheck is idempotent; safe to call when already unchecked
- Returns success immediately if already in unchecked state
- Pair with
checkfor state management - Use
is @ref checkedto verify state before or after - Radio buttons cannot be unchecked (select different option instead)
- Some apps may trigger onChange events even on no-op uncheck
- Always verify critical state changes with
iscommand - Useful for resetting forms to default state