AppleScript: How to close notification alerts from a specific application?
Solution 1:
I tested the following example AppleScript code under macOS 10.12.5, and it closed the Alerts style messages from Calendar.
tell application "System Events"
tell process "NotificationCenter"
set windowCount to count windows
repeat with i from windowCount to 1 by -1
if description of image 2 of window i is "Calendar" then
click button "Close" of window i
end if
end repeat
end tell
end tell
Note: This is example AppleScript code which contains no error handling. Add appropriate error handling as needed, required and or wanted.