Clear Notifications - Ventura Macro (v10.2)

Download: Clear Notifications - Ventura.kmmacros (2.2 KB)

3 Likes

This is a good site for generating test notifications. Test Web Push Notifications - CleverPush

I don't see a question, but I assume you're wondering why it doesn't work.

Try this instead:

tell application "System Events"
	try
		set _groups to groups of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter"
		
		repeat with _group in _groups
			
			set _actions to actions of _group
			
			repeat with _action in _actions
				if description of _action is in {"Close", "Clear All"} then
					perform _action
					
				end if
			end repeat
			
		end repeat
		
	end try
end tell

Thank you, your suggestion is a good way to repeat over a list. The original solution works but checks for "Clear All" first before moving on to check for "Close". With the list you suggested, for some reason a group of alerts that is expanded, this will close all but the last alert. ¯_(ツ)_/¯

1 Like

Yours does work better! The reason it didn't work for me was the end tel typo, which I missed at first. Once that was fixed, it works great and, as you mentioned, doesn't leave one notification at the end. :+1:t3:

Ahh... I missed that too. Must have hit the delete key right before I shared this. I updated the macro and the jpeg to show the missing "L".

For anyone who doesn't know what is going on (because its since been updated), the original macro was missing 1 "L" in the last "tell" of the script, so it was actually "tel" ... which will break.

Thanks for the good catch @noisneil

1 Like

Thanks for that macro. Clearing notifications was going to be my next project. Now I'll have to think of something else to do.

Emyr

My pleasure. I'm sure this macro can be tweak to perform better. I'd love to see your updates if you work on it.