Overview
Performs a right-click (control-click) on an element to open its context menu. The command returns the menu tree inline after a brief delay, allowing immediate interaction with menu items.Syntax
Parameters
Element reference from snapshot (
@e1, @e2, etc.)Response
Response Fields
The action performed (
right_click)The element reference that was right-clicked
The context menu tree with refs assigned to menu items
role: “menu”children: Array of menu item nodes with refs
AX-First Strategy
The right-click command uses this priority:- Try
kAXShowMenuActionvia accessibility - Try control+click via keyboard simulation
- Right-click at element center via mouse events
- Waits 200ms for menu to appear
- Captures menu snapshot with refs
- Returns menu tree inline
Usage Examples
Right-Click and Select Menu Item
Context Menu on Text Selection
Desktop Item Context Menu
Menu Interaction Pattern
Common Use Cases
- File Operations: Get Info, Rename, Delete in Finder
- Text Editing: Cut, Copy, Paste in text fields
- List Items: Context actions on list/table rows
- Desktop: Application and file management
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 | Element doesn’t support context menu | Element may not have a context menu |
Notes
- Menu tree is returned inline in the response
- Menu refs are valid until menu is dismissed
- Run
snapshot --surface menuto re-capture menu if needed - Some apps show different menus based on selection state
- Use
wait --menu-closedto detect when menu is dismissed - Clicking outside the menu or pressing escape dismisses it