Using Extra Buttons to Select Next Action on Prompt for User Input

This is an example macro using the result button variable.
I had a number of options in the prompt for user input,
so as well as the OK and Cancel, I wanted the ability to
set the options to specific defaults.
Just to show the principles, I have only one input field and
four buttons OK, Cancel, Pages setup and Option.
The first test is incorrect as it uses the Button on test.
The second is correct as it uses the Result Variable test.
This means it is very easy to give the user a choice and vary the macro
based on the button selected. Hope this helps.

1 Like

I can't see the picture in this thread... too old perhaps?
I would love some more input on how to use buttons other than OK/CANCEL, like for instance how to use the button HELP effectively.

Thanks for sharing your macro, except that the actual macro was not uploaded. See How To post/upload your script/macro.

So if IF statement only works with Variable trigger, why it has Button trigger?

See below macro.

Actions, like the If Then Else action do NOT have triggers. Only Macros have Triggers .

I'm not sure I understand your question, but maybe the below Macro will help.


Example Output

image

image


MACRO:   Demo Use of Buttons in Prompt for User Input [Example]


#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/6/0/60abdf61e4b018f876b5ab1b00ad2e18c22ef7f3.kmmacros">Demo Use of Buttons in Prompt for User Input [Example].kmmacros</a> (55 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---



![image|479x1921](upload://tPNlimXsT8Izz9YikQi9JEGDcLL.png)
3 Likes

Hey presto!

So button linked to variable will work.

Thanks again Michael.

You've done it again.

Beautiful code.

1 Like

Great example, thanks!

Hi, I'm trying to create text reformatting options with user input. I've managed to make some adjustments to suit my need based on the macro created by @JMichaelTX, but I couldn't figure out how to "paste" the reformated clipboard text automatically after clicking on one of the buttons. Will appreciate any guidance as I'm an absolute noob in KM! I appreciate any help on this. Thank you!

Paste as?.kmmacros (8.3 KB)

P/s: Just realised Mr. JMichaelTX status, rest in peace :pray:

Take a look at Literary Toolbox III and Text Toolbox I, specifically the Text Toolbox. It includes what you're doing but it also shows how to do it in two different ways (some case changes use Keyboard Maestro actions and others use Perl).

1 Like

Using the Paste action?

1 Like

Thank you! Figured I have missed the "paste" in action in the macro LOL

2 Likes

Hi @likeaboy - just a couple of bits of advice for simplifiyng your Macro (and for future Macros)

  1. You don't need to save %PromptButton% to a Variable to use it in the Switch Case.

image

You can reference it directly like this:

image

  1. I don't think there is any need for putting all those Actions in an "Execute Actions Until Conditions Met" containing Action. There are only two outcomes from your Prompt - pressing one of your buttons either filters the text or Cancels the Macro. The reason @JMichaelTX had put them in an "Execute Actions Until Conditions Met" in his example Macro, was that he had included a "Help" Button as a third possible outcome of the User Prompt and he wanted the Prompt to remain until the User had chosen another option other than Help.

Of course your Macro will still work without these simplifications - but I've found it good to reduce Macros down to their essential Actions as it makes debugging them much easier if things don't go as you expect. This is especially true for longer Macros where there might be loops within loops and other complications.

4 Likes

Very nice! Learning something new everyday from this amazing KM community!

2 Likes