Thursday, August 23, 2012

Dialog boxes in applescript

Dialog boxes are very easy to make in applescript.  Script editor comes with a list of commands.  hold down control and click on your mouse this menu appears.  Go to Dialogs and dialog -2 buttons 2 actions.


This will appear in your script editor. 
display dialog "" buttons {"", ""} default button 2
if the button returned of the result is "" then

else

end if
----------------------------
Here is some sample code:
------------------------------
display dialog "Is it the weekend?" buttons {"Yes", "No"} default button 2
if the button returned of the result is "Yes" then
say "awesome"
else
say "BOO"
end if

This is my dialog box:


You can see from this the string between the first "" is the question and I have two buttons for each "" and the button highlight is the second one.

And each button just says either awesome or Boo.