Prompt for User Input with Custom Text for the Referenced Variable

Continuing the discussion from Dynamic Default List for Prompt for User Input (Example):

Is there a way to use custom text for the text next to a prompt box where you type information in or choose from a drop down. I want what is returned to go to a variable but I would prefer to not show the name of the Variable that it is referencing in the User Input Prompt since the Variable name is formatted in a way that is helpful for me to organize but not very end user friendly, plus it gets truncated in the dialog box.

image

I am guessing the only way to do this would be with custom HTML which I am having difficulty wrapping my head around but just wanted to confirm if that was truly the case.
https://wiki.keyboardmaestro.com/action/Custom_HTML_Prompt?s[]=html

Howdy, one simple way (that may or may not work for you), is to simply type whatever you want the prompt to say on the left-hand side (which will make a new variable), and then set your original variable to that variable in the prompt.

For instance, in the prompt I used Whatever you want here, and immediately after I set the Your original variable to that initial variable.

Not fancy, but it might work for your needs. Likely others who are more experienced will chime in with better suggestions!

Modify variables.kmmacros (2.3 KB)

1 Like

Hey @skillet,

See the wiki: Prompt for User Input Action

Look for the double-underscores under the subsection:

How to Store a Different Value than Displayed

-Chris

2 Likes

Thanks for supplying the proper way to go about this. I was unaware of this feature. I'm going to implement this in a few of macros now.

2 Likes

Keep in mind that this method also works in the Prompt With List action.

Actually now that I read that, it looks like it's referencing how to show a default value in the actual drop down menu (which I use in a few of my macros)...but I believe OP was asking how to show a value other than the variable name to the left side of the drop down menu...perhaps I'm misunderstanding..?

1 Like

Try it out...

Haha, dang...I need coffee or something. I went back and read it again and it just clicked. Thanks! :laughing:

I understood @skillet's question differently: I thought they didn't want the prompt to show, for example,

Pom Ses App Intent

If that's what was meant the wiki page gives a solution just a bit further down under the heading How to Hide a Variable Prefix in the Prompt.

So if the prompt is set to:

Pom Ses App Intent__Attempt

it would be displayed in the form as

Attempt

and the value typed into the form would be returned in the KM variable named:

Pom Ses App Intent__Attempt

@tiffle you are exactly right I was trying to wrap my head around this and that was exactly what I was getting as the result. I didn't want to change the Variable to Pom See App Intent__Attempt but the display name is solved. I will read more down the page and all of this on the Wiki to get some more info on this display.

Hopefully I can show "Attempt" in the display dialog and have that stored in "Pom Ses App Intent". I just wanted to post soon to clarify, thanks all!

It seems very strange that it works differently for the selectable items.

From Wiki

For example “B__Good|F__Fail|C__OK|B__Good|A__Excellent” would be shown as:

Fail
OK
Good (selected by default)
Excellent
but would set the variable to A, B, C,or F as appropriate.

From Wiki

So, you can hide the prefix if the variable name starts with a prefix followed by two underscores. Then the label will show only the latter part of the variable name.

For example, if you enter “MyMacro__Text Message” in the variable name field of the Prompt for User Input action:

** It will display a label of “Text Message”:*

** But the actual variable name that is set will be just as you entered it: “MyMacro__Text Message”*

1 Like

Maybe you are confusing variables with values (options)?

“B__Good|F__Fail|C__OK|B__Good|A__Excellent” are options (on the right side), but MyMacro__Text Message is a variable name (on the left side).

1 Like

I actually just thought that and you beat me to it. It just seems strange to me that if you are just trying to display something different the logical thing would be that "Pom Ses App Intent__Intent" would save to the variable "Pom Ses App Intent" From what I can tell this can't be done so I will just settle on storing the variable name as "Pom Ses App Intent__Intent" or better yet "Pom Ses App__Intent"

4 Likes

I felt the same way when I first started messing with user-prompts years ago.

I'm sure @peternlewis has a logical reason for this, and let's see if we can get him to explain at least in brief.

In your case it doesn't really make sense to use “Intent” twice.

Change;

Pom Ses App Intent__Intent

To:

Pom Ses App__Intent

I don't use this feature very often, so I don't have a normal convention, however if I did it would probably be:

Pom_Ses_App__Intent

Or camelcase:

PomSesApp__Intent

I particularly dislike seeing spaces in variable names.

Conventions like this make variables easier to identify at a glance as variables.

-Chris

1 Like

I guess that depends on “logical” to who.

Sure, the reasoning is pretty simple - the default normal behaviour has you configuring the variable name. The __ simply changes how that variable name is displayed to the user in the prompt. Hence the whole thing is the variable name, and the part after the __ is displayed to the user.

Primarily this was provided to allow for prefixes in variables, since a common convention was to use a prefix for a particular variable to keep your variables from different macros separate.

Now there are Local and Instance variables, so a prefix is not necessary if you are using Local or Instance variables, and in version 10, the “Local” or “Instance” is removed from the display so you can use, for example “Instance Intent” and it will display “Intent”, but the variable will still be “Instance Intent” and will be local to this execution instance.

5 Likes

That's a great point, I think I will start using lower camel case then for my variables in the future.

Thank you Peter for the explanation, that was helpful.

1 Like