AppleScript: Choose from list AND custom buttons?

I want to create a script which will have the user choose from different options in a list. I want there to be two buttons, Play and Select. Play will play a sound based on the user's selection, select will assign the option to a variable and dismiss the pop-up.


I have tried: choose from list {"Option 1", "Option 2", "Option 3"} with prompt "Please select which sound you like best" buttons {"Select", "Play"} default button 2


However, it seems that I cannot use the "buttons" parameter with a list. Is there any other way to do what I want?

 MacBook Pro with Retina display-OTHER, OS X Mavericks (10.9.5), 15 in, Late 2013, 256GB, 8GB RAM

Posted on Jan 9, 2015 12:21 PM

Reply
2 replies

Jan 9, 2015 12:50 PM in response to stevejobsfan0123

Here is the correct syntax that you are permitted with a choose from list syntax (see AS Language Guide)


set mychoice to (choose from list {"Option 1", "Option 2", "Option 3"} with prompt "Please select which sound you like best" default items "None" OK button name {"Play"} cancel button name {"Cancel"})

-- choose from list cancel button returns false, not -128, as do other choose syntax do.

if mychoice is false then error number -128 -- user canceled

You could set your Cancel button name to {"Select"}, and then test for the false return for further select processing.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript: Choose from list AND custom buttons?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.