I wanted to create a script that would open up a dialog box with a list of buttons, that have different links when I click on them. Does anyone know if applescript has that capability? If not then can I get any insights on something that would?
An example is sort of like this:
Open up script
Button1 -> Google.com
Button2 -> Aol.com
Button3 -> Yahoo.com
In Script editor you can have up to three buttons.
In a new document crtl Mouse click on the document. And you will get a contextual menu.
Go to the Dialogs sub menu and you will see a list of choices.
Choose the Three buttons three actions option.
And you will get this code placed in the document.
You would then set it up like so:
The Main problem is the limit of buttons.
If you use all three for your sites you have no way of doing any other action; like Cancel.
The easier option is to do it as a choose from list like @Zero has answered.
This way you can have more actions in the form of a list item and retain the option of a Cancel button.
UPDATE:
The Modern Script Editor.app allows you to use Objective - C in your Applescript. This is done with ApplescriptOBJC bridging language.
There are plenty of lessons and example on the web.
The advantage of this is that for the task above you can create a simple app from within Script Editor that has a window with buttons and actions.
This example should show you how to add any buttons you want, even if you do not know any Objective - C or ApplescriptOBJC which is the bridging language between Applescript and Objective - C.
The aim of the script is to be Saved as a Stay open Application
And then run from the Dock or as I do from the Script Editor Applescript Menu.
Each button is linked to an action which also includes a quit action. This is a simple way of keeping the app only running when you need it.
Yes, there is the
choose from list
command. Try following script, just make sure the links and labels in the two lists are in corresponding order:For opening a single link, you can use like below,