I need to define the “on alert ended” handler to handle multiple alerts, each with different buttons and responses. As it stands, you can only have one handler for the event, so I need to execute the actions conditionally, but I can’t find anything in Apple’s documentation about how to tell the handler what to do for each individual alert. Basically, I need this line of code:
on alert ended theObject with reply theReply
if [a certain alert which I don't know how to identify comes up]
if button returned of theReply is alternateButtonTitle then
tell application "Terminal"
launch
do script "sudo /usr/local/bin/vpn_uninstall" in window 1
set frontmost of window 1 to true
end tell
quit
else
quit
end if
else [if the other error comes up]
quit
end if
end alert ended
And the first alert is invoked by this line
set theReply to display alert dialogText as dialogType message dialogMessage default button defaultButtonTitle alternate button alternateButtonTitle attached to window "mainWindow"