Use "prompt for user input" to ask for text that gets set to a named clipboard after hitting OK

I tried to search the forums but couldn’t quite find the answer to this. I’m sure it’s simple but I’m new to KM and just can’t figure it out.

I want the Prompt For User Input popup window to be able to take the text I type into it and copy that text to a specific named clipboard called “File Name”

How can I do this?

The first question would be - why are you using a Named Clipboard to store plain text (which is all you can type into a Prompt For User Input window)? You probably should be using a variable (which is exactly what the Prompt For User Input window gives you).

Other than that, it's pretty trivial:

Keyboard Maestro Actions.kmactions (1.3 KB)

EDIT: Note that it should be %Variable%Text%, not two percent signs in the middle as shown.

But again, what you are suggesting makes little practical sense so it may be you are asking the wrong question and should instead explain what you are actually trying to accomplish.

Why is a named clipboard not a good choice for plain text?
I have a number of fields in a document template in a pro audio program I work in that have the words “Name” in them that I need to replace with the actual file name.
I want the macro to prompt the user for the actual file name that will replace "Name"
What you described helped and completely worked.
I’m not sure I understand why the way I’m going about it doesn’t make sense.
Educate me, please.

A named clipboard offers no advantages for plain text. They are usually used for storing copies of the System Clipboard (which can contain all types of objects, not just plain text).

See Named Clipboards.

There are numerous advantages in using KM Variables for plain text.
See Keyboard Maestro Variables.

At the end of the macro, you can set a Variable to "%Delete%" to delete it, which is usually a good idea if you don't need the last value of that variable for future use.

Here's what I have currently that works quite well. I'm prompting the user for a prefix that will replace a word that's currently there in all of the items. Then repeating it by the defined number of items, which the user was also prompted for.
Image and macro attached.
(EDIT: that last Return keystroke need to come at the very end and NOT in the Repeat Actions section -- but otherwise all else is correct)

Rename Prefix For A Definted Number Of Items - example.kmmacros (34.8 KB)

The Repeat action count, like (almost) all numeric fields in Keyboard Maestro, is a numeric text field, not a token text field, so variables need to be used without adornment, specifically you should use "PrefixQuantity", not the text token "%Variable%PrefixQuantity%. That is why it is red and says it is invalid.

The reason that using Named Clipboards is not overly sensible in this case is that Named Clipboards allow storing styled text and images. For storing just plain text, while a Named Clipboard can do that, it's unnecessary - a variable is sufficient.

So after your first action, the variable Prefix holds the text you wish to paste. Forget the PrefixName clipboard and the second action which sets it, and replace the Paste from Named Clipboard action with Insert Text by Pasting "%Variable%Prefix%".

Or in this case, since you wish to paste it multiple times, you could just use the Set Clipboard to Text action before the Repeat:

And then in the loop, simple use the Paste action.

For those of you who, like me, used the above image to learn how to user input, there is small typo.

%Variable%%Text%

should be written as

%Variable%Text%

I mean when I replaced

%Variable%%Pearltrees_Search%

by

%Variable%Pearltrees_Search%

it worked like a charm.

2 Likes