Prompt For User Input: Pop-up Menu - How to remember last selection?

Keyboard Maestro has a function called Prompt For User Input where you can create a pop-up menu by using the following syntax:

option 1|option 2|option 3

In this example, option 1 will be the default because it is the first in the list.

Is there away to recall the last selected option? E.g. If I select option 3, then the next time the macro runs it will select option 3 as default.

1 Like

Yep, very easy.
Use the same KM Variable as the default value for the menu items, like this:
Let's say the variable that your are setting is named "DND_ABC__Color".
Then use this for the values field:
|%DND_ABC__Color%|Red|Green|Blue

The one issue with this is that if "DND_ABC__Color" is undefined the value field will show nothing. So you need something like this before the Prompt, usually at the top of your macro:

IF DND_ABC__Color is empty
THEN Set DND_ABC__Color to "Red"

image

image

BTW, my KM Variable naming convention:

  • "DND" -- means "Do Not Delete"
  • "ABC" -- are 3 or 4 characters that identify the main macro where this variable is used.
  • "__" -- two underscores are used so that only the text to the right of them are display to the user when the Prompt is shown.
5 Likes