Dialog Display in AppleScript

Good morning,

I use Automator to create a program and I know how to add an AppleScript script to it.

I'm looking to create an AppleScript that displays a dialog box with a question and two options (in the form of two buttons), both of which trigger an app to open, but different, when clicked.

I don't use Automator's "Ask for confirmation" block, which indeed displays a dialog box with two options, corresponding to what I'm looking for, but I can't customize the action of the two buttons.

Can you help me ? Or give me sample code?

Thanks in advance :)

Answered by ssmith_c in 752596022

maybe this will help you get started:

try
	set theReply to (display dialog "this is my prompt" buttons {"Cancel", "first thing", "second thing"} default button 1)
	
	if the button returned of theReply is equal to "first thing" then
		display dialog "you chose the first thing"
	else if the button returned of theReply is equal to "second thing" then
		display dialog "you chose the second thing"
	else
		display dialog "you chose nothing"
	end if
	
on error e number n
	display dialog e & " (" & n & ")"
end try
Accepted Answer

maybe this will help you get started:

try
	set theReply to (display dialog "this is my prompt" buttons {"Cancel", "first thing", "second thing"} default button 1)
	
	if the button returned of theReply is equal to "first thing" then
		display dialog "you chose the first thing"
	else if the button returned of theReply is equal to "second thing" then
		display dialog "you chose the second thing"
	else
		display dialog "you chose nothing"
	end if
	
on error e number n
	display dialog e & " (" & n & ")"
end try

Many thanks !

Dialog Display in AppleScript
 
 
Q