Browse the docs

Show an HTML prompt

Shows a web page as a prompt, for Keyboard Maestro's Custom HTML Prompt in an imported macro. New macros use Show a panel.

Show an HTML prompt title

Keyboard Maestro: CustomPrompt

Details #

The importer writes this step for a Keyboard Maestro Custom HTML Prompt, so the page keeps its layout, styling and scripts. It is not in the add-step list and Make with AI does not use it: a new macro that wants a window uses Show a panel, which is drawn with real Mac controls.

The page runs in a web view with no network: nothing is fetched from the web, no link or form takes the view elsewhere, and the page is not given an address. It talks to the macro through the same calls Keyboard Maestro's pages use:

  • KeyboardMaestro.GetVariable("name") gives the text of a variable of the run.

  • KeyboardMaestro.SetVariable("name", "value") sets a variable when the page ends.

  • KeyboardMaestro.Submit("Button") (or Finish) ends the prompt with that button. KeyboardMaestro.Cancel() cancels it.

A form works without a script. Pressing a submit button, or a button outside a form, sets one variable for every named field (a checked checkbox gives its value, or Yes; an unchecked one gives No) and ends the prompt with the button's value or text. A named field starts with the value of the variable of the same name. Escape cancels.

The step's output is {button, variables}. Every variable the page set is a variable of the run, and htmlResult holds the button.

Parameters #

ParameterTypeRequiredValuesWhat it does
filetextA file to read the page from when html is left out. A leading ~ is expanded. Files over 2 MB are refused.
heightnumber
htmltextThe page.
intotextThe variable that receives {button, variables}.
namesrecordThe page's variable names to the macro's, for the names that differ ({"Local_name": "name"}). The importer fills this in.
titletextThe window title. Defaults to the macro's name.
widthnumber, height: The window's size in points. Defaults 600 by 400.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

A page with one button
Do
  1. Show an HTML prompt “Hello”
  2. Show “{{ htmlResult }}: {{ who }}”
Open in Switchboard to try it

Gotchas #

  • A dry run does not show the page.

  • Cancelling fails the step with "cancelled by you", like Ask for input.

  • Keyboard Maestro's other calls (running AppleScript from the page, for instance) are not there.

See also #

Show a panel, Ask for input