Create a folder based on user input

Hi! I am trying to make a simple macro just for the sake of learning my way around KM a bit better. I just want to trigger something based on user input so in my example if the user clicks on No then a folder named No! is created on the desktop and a bing sound is played. If the user clicks yes then a folder names Yes! is created.... I have attached a script that of course does not work (because I made it lol) but I would like to know the correct structure. This is because I am working on a bigger project and need to run more actions based on the yes or no answer so creating a folder is just to get the button working so I can learn how it is done. Hope that makes sense :grin:
Create folder yes or no.kmmacros (3.7 KB)

With a Keyboard Maestro prompt, when you click on a button the name of that button name is saved to the token %PromptButton%.

So, to test what button was pressed you can check what the token %PromptButton% contains. i.e. if it contains "Yes" then do one thing and if it contains "No" do something else.

And instead of using If Then Else a Switch Case Action is probably better here. Apart from anything you can test for more buttons than just two.

Also, it's always a good idea to keep a "Cancel" button on the Prompt to stop the Macro if you need to.

So, here's one way to get your test Macro working:

If yes do this if no do something else! v2.00.kmmacros (3.5 KB)

Click to Show Image of Macro

2 Likes

Hi Zabobon,

That is what I wanted to achive. So I was kind of close but the main thing is that I have learned and can continue with my script. Thank you very much for taking the time to help me.

Regards,

Margate

1 Like