Nono.MA

Display macOS Dialogs, Alerts, and System Notifications with AppleScript

DECEMBER 7, 2018

Here's a note on how to display dialogs, alerts, and notifications on macOS with AppleScript, useful to automate day-to-day tasks you do with your machine, or even create complex programs.

(To the uninitiated, you would run this code by opening the AppleScript Editor (on macOS), pasting the code there, and hitting run.)

Dialog and Alert1

display alert "This is an alert" buttons {"No", "Yes"}
if button returned of result = "No" then
	display alert "No was clicked"
else
	if button returned of result = "Yes" then
		display alert "Yes was clicked"
	end if
end if

System notification

display notification "Have a simple day!"

CodeMacos