Prompt for User Input in Keyboard Maestro

One of the great things about Keyboard Maestro is the ability to design a UI for your macro. Using the `Prompt for User Input` block, the macro can be dynamic in how it works, or perform different functions based on user choice.

The prompt can contain an entry field, checkbox, dropdown, or buttons selections. The result is stored in a variable.

I have several macros with prompts, such as the size of a RAM drive, the number of times to click the mouse, a folder name, and what to rename a file. Those results are then used later in the macro or passed to the shell to move files, or create volumes.

A broad list of examples can be found at the Keyboard Maestro Wiki:

Keyboard Maestro- Prompt for User Input

The following examples are the ones I use most:

Text field: Variable and default value
Checkbox: Variable and 0|1 indicating checked or not (value must be 0 or 1, separated by the pipe)
Dropdown: Variable and Item1|Item2|Item3|Item4. Values are separated by the pipe symbol.
Buttons: Use the `%PromptButton%` token to get the name of the selected button. This will store the text of the button name. If you have a button called `Move`, the word Move is stored in `%PromptButton%`. You can assign a variable to the result of `%PromptButton%` to use at different stages in the macro.

Here is a simple example of prompting for input. It’s a trigger I use to test how a button handles repeated clicks.

The default number of clicks is set to 10. This can be changed at runtime.

The value is stored in `instance__clicks`
`instance__clicks` is then used in the Repeat Action block.

The click action is repeated based on the variable. The click action takes place under the current location of the mouse pointer. The move is set to 0,0 from current location.

To make note, `instance` means the variable is local to the currently running macro.


Author Signature for Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.