Custom HTML prompt

I just had a look at the Custom HTML prompt action.
This was the example from the KM library.

As the help states, then text entered in the fields are returned as variables.

In the example there is this code:

		<label class="col1">Email:</label> <span class="col2">
	<input name="Web_Email" class="input" type="text" id="email" />

When I fill in text in the Email: field I get a variable called “Web Email”. The input name is “Web_Email” with an underscore.

Why is the underscore removed, or is there somewhere I not can find in the HTML where the variable name is defined?

Nope, you’re doing it properly.

Keyboard Maestro requires you to replace spaces with underscores in a lot of circumstances where multiple words aren’t allowed (URLs, environment variables, etc.). This does of course make it harder to actually have underscores in your variable names. My recommendation would be to use hyphens or camelCase.

Do you know it it happens for other characters than space?

No. Spaces are turned into Underscores when variables are represented pretty much anywhere externally (except accessed explicitly by name).

Exploring the excellent HTML custom prompt action, I notice that the sample code uses three methods of the window.KeyboardMaestro object:


Does window.KeyboardMaestro expose any other methods or properties than can be used in those prompt pages ?


Found it – hadn’t noticed the Help item in the action menu

Yes, the shiny new help for all the:

is a very nice bonus for 7.0 - and all available directly from within the app by holding down the Option key will select Edit ➤ Insert or adding a Trigger, Collection or Condition.


If we want to include a local .js library in an HTML prompt (rather than having it downloaded over a network at run-time), do we need to load the js as a string into the html source, or is there any local folder in which the webkit page looks for local resources ?

I don't think there is a default folder for the HTML Prompt. It appears from this example, that you need to set a <base href> in the HTML:

Fancy Mac-Like HTML Prompts Library - Macro Library

document.write('<base href="' + window.KeyboardMaestro.GetVariable('htmlAssetsFolder') + '">');
<title>Dialog Box</title>
  <script src="js/jquery.js"></script>
  <script src="js/jquery-ui.js"></script>
 <link rel="stylesheet" href="css/jqueryui.css">

  <link rel="stylesheet" href="css/macdialog.css">


1 Like