Dynamically Adding a List Item When Using "Prompt With List" Action

I'm using the Prompt with List action to select and insert tags from a list. It is working great for as far as it goes. I'd like to extend this by both adding items to the list if it doesn't appear there and insert by pasting the new item. The new item would be available in the list the second time the macro was run.

I've not gotten far with the mental logic of how this might be accomplished. I think what is blocking me is some setting in the gear menu of one of the actions.

This is what I have so far but I think I may be barking up the wrong tree.
This starting to work. It picks from the list all right but a new item causes the system to beep. But 2 taps on ESC and the #test is pasted.

Hello @kestrelcreek,

I think I've seen you ask a similar question before. I'll add my two cents.

You can use Prompt with List via a text file that you can append to. This file can be created and accessed from the location of your choice. In my example, I just placed the file on the Desktop.

See my example below (animated gif first and then the actual image of the macro). I think this is what you want.

Basically, if you want to add to your tags list you can select or type the #add from your list of selections (you can make it whatever you want, this is just an example), add your #name and then it will continue to function. Next time you launch your prompt with list, the new tag will be available (in your file and in your macro) for your next iteration.

ScreenFlow

You may need to right click and open in a new window to see this.

Let me know if this suits your needs.

KC

5 Likes

Just one additional suggestion to add to @kcwhat's excellent example - if you Enclose the Prompt an "Execute Actions Until Conditions Met" Action and make the Condition to break from the loop "Until the Variable Listings is not empty" then you don't have to reopen the Prompt with List if you add a new item. The List will stay open when you add any new items and only move on when you make a selection from the existing items on the list. Hope that makes sense - hard to upload an example when I don't have the original Macro.

Here is what I mean (in a different Macro example that I made for myself when I was trying to figure this stuff out). In this case the Dynamic List is stored in a Variable rather than a File and the Prompt is a Prompt for User Input rather than a Prompt from List. But the general idea is the same i.e. a list that can be added to or chosen from. And it shows the idea I mentioned above of enclosing in a Loop to keep the Prompt open if a new item is added.

EXAMPLE Dynamic List from Prompt v2.00.kmmacros (14.0 KB)

Click to Show Image of Macro

EXAMPLE Dynamic List from Prompt v2.00-Animated GIF

3 Likes

@kestrelcreek,

In addition to Mr. @Zabobon's useful creation, You can also create a tag adding macro for the above **List Prompt macro.

Using a one action macro below (I called it Add to List Prompt Subroutine for this example).

image

Then you can use your Trigger Macro by Name macro to easily create the tag you want using the //.

For Example:

It's ridiculous the amount of many tricks @peternlewis has placed into Keyboard Maestro.

If hope one of these solutions work for you.

KC

6 Likes

First, thank you both for taking the time to reply. Email notifications where lost in a slew. Here I'd thought I was being ignored. I should have known better.

@kcwhat your example shown in the GIF, is awesome. Clearly, you understand where I misunderstood. You make it seem so easy. Your solution is elegant and doesn't change how the user interacts with tag insertion now.
@zabobon your solution is a bit more sophisticated.

I do prompt from a variable rather than I file but I thinking now that prompting from a file might be more appropriate.

2 Likes

An advantage of saving/reading the data from a text file rather than a Variable, is that the same file can be available to multiple computers that have Keyboard Maestro in sync (by storing that text file in Dropbox or iCloud Drive for example).

An advantage of storing in a Variable is the exact reverse - i.e. the data is unique to each computer as Variables do not sync.

Just something to consider if you sync Keyboard Maestro across multiple Macs.

2 Likes

I’m glad you see value in one of our solutions. I’m sure there are many variations that can be implemented. Be sure to click the checkbox for the solution that solved your issue. That way, in 2 years when one of us forget how to implement this, we can find it. :grinning:

Take care.
KC

1 Like