Dismissing multiple notifications in BigSur with applescript

Hello!

How to dismiss multiple notifications in BigSur with applescript?

Previously, I used this applescript but it doesn't work in BigSur.

tell application "System Events"
	tell process "NotificationCenter"
		set numwins to (count windows)
		repeat with i from numwins to 1 by -1
			click button "Close" of window i
		end repeat
	end tell
end tell

Is there another way to do so?

1 Like