The Shortcuts app provides a capable suite of dialogs, but they can be limiting in some circumstances. The open-source, command-line swiftDialog app (thanks laughingtiger) can be used in a shortcut when the native dialogs won’t do the job.
The following is a simple example of a 3-button dialog:
There is an issue with the above shortcut in that the Enter key is mapped to Button1 and the Escape key is mapped to Button2. There’s no option to remap the Escape key to Button3, and the alternatives are:
enable the --hidedefaultkeyboardaction option, which disables the Enter and Escape keys; or
make button 2 the Cancel key.
The swiftDialog app is available here:
The following shows list and radio button dialogs:
The following might be a better approach to a 3-button dialog in that the Enter and Escape keys work as expected. The shortcut returns 0 for Option One and 3 for Option Three. Pressing the Escape key stops the shortcut.
Very interesting post, thank you. I have AppleScripts (run in sequence) that also contain an Automator workflow, and I’m wondering, if the Run Shell Script can be included as a workflow, that would be included in an AppleScript sequence?
Homer712. I know nothing about Automator, so I can’t answer the specific question you raise. However, the swiftDialog app does run correctly and return the in expected value in Automator.
So, I have a project for tomorrow’s morning coffee. I’ll be installing the swiftDialog app and first playing around with your Shortcuts, then seeing if I can work them into some of my AppleScripts. Thank you for posting this.
The Shortcuts app has an Ask for Input dialog, but it’s pretty limited. SwiftDialog allows you to do much more, and the following is only a simple example. The output of the dialog is set to be a JSON, which is then made into a dictionary with the Get Dictionary from Input action. Standard error is redirected to /dev/null to prevent the shortcut from stopping and reporting an error if the cancel key is selected. Additional error handling is still needed, though.
This probably just doesn’t work, but I wondered if anyone might know how to import a JSON to swiftDialog. I made numerous changes but it just wouldn’t work. I was going to inquire on the developer’s GitHub site, but this is more of a help question than an app issue.
The swiftDialog app has the ability to update the content of a dialog while the dialog is active. This is done by sending a command to a log file. The list of items that can be updated is extensive (here) and includes title, message, dialog size, icon, and button text. The following is a simple example:
The first action of the shortcut runs swiftDialog in the background, which is required. Several issues can result, but I don’t know if these would be of much consequence in an actual shortcut.
I recently posted a Roll-the-Dice AppleScript in the Mac OS X forum. It uses the swiftDialog app, and I’ve included a shortcut equivalent below. The shortcut differs from the AppleScript only in that the shortcut is a bit slow and does not contain a roll-again option.
The following shortcut demonstrates: 1) quoting selected text with markdown in a swiftDialog; 2) setting the dialog icon to the icon of a macOS app; and 3) a help screen. The nominal purpose of the shortcut is to count characters in a selection in the frontmost app.