**This is an old revision of the document!**
Table of Contents
Execute JavaScript in Custom HTML Prompt Action
The Execute JavaScript in Custom Prompt action (version 7.1+) allows you to execute a specified JavaScript in any active Keyboard Maestro Custom HTML Prompt.
The Execute JavaScript in Custom Prompt action is the functional equivalent for the Custom HTML Prompt to these actions:
Example
Note the purpose of this example is to close an existing HTML Prompt window, and it calls a custom JavaScript function already in the Custom HTML Prompt. The Action option of “asynchronously” is chosen to avoid timeout of the Action. Otherwise, the Action will wait for a response from the HTML Prompt, which will never come.
Source of Script
The JavaScript may be from any of the following:
- From a JavaScript file
- From the text script in the Action
- Using any custom functions in the HTML Prompt.
Target of Script
The JavaScript is executed in a specific Custom_HTML_Prompt action with a matching data-kmwindowid, or all Custom HTML Prompts if no windowid is specified.
Results of Action
This Action can (optionally) return the results of the JavaScript:
- ignore results
- display results in a window
- display results briefly
- display results large
- type results
- paste results
- save results to variable
- save results to clipboard
- Either the system clipboard or a named clipboard
- asynchronously
- Results are not saved
- The macro immediately continues to the next action, which runs in parallel with the current action
If the results are to be saved to a variable or a clipboard then further text areas appear in the action allowing you to specify the variable or specific clipboard.
Access to Keyboard Maestro Variables
The JavaScript can access variables by using the window.KeyboardMaestro functions described in the Custom HTML Prompt action.
