peekaboo dialog
dialog wraps DialogService so you can programmatically inspect, click, type into, dismiss, or drive file dialogs without re-running see. Pass a target (--app/--pid plus optional --window-id/--window-title/--window-index) whenever possible so Peekaboo can focus the right app/window before interacting.
#Subcommands
| Name | Purpose | Key options |
|---|---|---|
click | Press a dialog button. | --button <label> (required), optional --app/--pid, optional --window-id/--window-title/--window-index. |
input | Enter text into a dialog field. | --text, optional --field <label> or --index <0-based>, --clear, plus --app/--pid, optional --window-id/--window-title/--window-index. |
file | Drive NSOpenPanel/NSSavePanel style dialogs. | --path <dir>, --name <filename>, --select <button> (omit / default clicks OKButton), --ensure-expanded, optional --app/--pid, optional --window-id/--window-title/--window-index. Save-like actions verify the file exists and return saved_path. |
dismiss | Close the current dialog. | --force (sends Esc), optional --app/--pid, optional --window-id/--window-title/--window-index. |
list | Print dialog metadata (buttons, text fields, static text) for debugging. | Optional --app/--pid, optional --window-id/--window-title/--window-index. |
#Implementation notes
dialogsubcommands share the same targeting flags as other interaction commands (--app/--pidplus--window-id/--window-title/--window-index) and use the same focus helpers before interacting.- Button clicks and text entry route through
services.dialogshelpers, which return dictionaries describing what happened; JSON output exposes those details verbatim (button,field,text_length, etc.). dialog inputaccepts either a field label (--field) or an index; when neither is provided it targets the first text field.--clearissues a Cmd+A/Delete before typing.dialog filecan both navigate to a path and fill the filename field, then clicks the action button you specify (--select Save,--select Open, etc.). Leave--pathblank to simply confirm the current directory.dialog filedefaults to clicking the dialog’sOKButtonwhen--selectis omitted (or set todefault). Prefer this when you don’t want to guess whether the button is labeled “Save”, “Open”, “Choose”, etc.--ensure-expandedexpands the dialog (Show Details) before applying--path. If noPathTextFieldis present, Peekaboo falls back to the standard “Go to Folder…” shortcut to reliably land in the requested directory.- For save-like actions (resolved by the actual clicked button title),
dialog fileverifies that the saved file appears on disk (5s timeout). On success it returnssaved_pathandsaved_path_verified=true. If you provided--path+--name, Peekaboo also enforces that the file landed in the requested directory (symlinks like/tmp→/private/tmpare normalized). - JSON output includes additional provenance for debugging without screenshots, including
dialog_identifier,found_via,button_identifier,saved_path_found_via, andpath_navigation_method(e.g.path_textfield_typed+fallback_go_to_folder). dialog listis invaluable before scripting a dialog: it prints button titles, placeholders, and static text so you can pick stable labels instead of guessing.
#Examples
# Click "Don't Save" on a TextEdit sheet
peekaboo dialog click --button "Don't Save" --app TextEdit
# Enter credentials into a password prompt
peekaboo dialog input --text hunter2 --field "Password" --clear --app Safari
# Choose a file in an open panel and confirm
peekaboo dialog file --path ~/Downloads --name report.pdf --select Open
# Save a file and verify the resulting path exists
peekaboo dialog file --path /tmp --name poem.rtf --select Save --app TextEdit --json
# Click the default action (OKButton) and include dialog provenance in JSON output
peekaboo dialog file --path ~/Downloads --name report.pdf --ensure-expanded --app TextEdit --json
#Troubleshooting
- Verify Screen Recording + Accessibility permissions (
peekaboo permissions status). - Confirm your target (app/window/selector) with
peekaboo list/peekaboo seebefore rerunning. - Re-run with
--jsonor--verboseto surface detailed errors.