My custom AppleScript for closing all notifications also broke during the update to Sequoia.
I got it working again with this script:
tell application "System Events" to tell application process "NotificationCenter"
try
perform (actions of UI elements of UI element 1 of scroll area 1 of group 1 of group 1 of window "Notification Center" of application process "NotificationCenter" of application "System Events" whose name starts with "Name:Close")
end try
end tell
Looks good and is part of what I also do in 4.700! (localized to support non-english macOS as well)
That only works for notifications that are "open" / visible and not in the notification center drawer though, right? (BTT's action also wants to close the notifications in notification center when it is opened)
That's correct! This was my intended functionality. A helpful new feature would be to add a setting in the Close All Notification Alerts / Notification Center action to toggle this on and off.
So many hours I've spent learning AppleScript, I have a love/hate relationship haha
Hey, when I try to run this script, I found that it only works on single notifications, not in group messages. If there are any group messages, it returns "missing value" as a result.
The built-in BTT functions work well for me, @asgeirtj. My issue only occurs when I run the Apple Script standalone, such as via the "Script Editor." As you can see in the video below, it only works when I close all the groups into a single notification at the end.
I fixed the script to also close Stacked (group) notifications:
tell application "System Events" to tell application process "NotificationCenter"
try
perform (actions of UI elements of UI element 1 of scroll area 1 of group 1 of group 1 of window "Notification Center" of application process "NotificationCenter" of application "System Events" whose name starts with "Name:Close" or name starts with "Name:Clear All")
end try
end tell
The difference is that I added or name starts with "Name:Clear All" in the whose query.
Note:
Andreas pointed out that this script only works for English macOS localization. I haven't figured out how to account for non-English localization.
In any case, Andreas' script works great too!
When using Andreas' script, don't forget to add your Shared Secret! i.e.
tell application "BetterTouchTool" to trigger_action "{ BTTPredefinedActionType: 289}" shared_secret "your_shared_secret"