Dismiss MacOS Big Sur notifications with keyboard I have long used an Applescript triggered from a keyboard shortcut to dismiss notifications on MacOS. It worked by simulating a click of the &quot;close&quot; button of every open Notification Center window.
Since upgrading to Big Sur (currently 11.0.1), notifications no longer have a close button. Instead, when you hover over them with the mouse, an &quot;X&quot; button will appear. For a person who has difficulty clicking precisely (I have a slight hand tremor), using the mouse/trackpad is difficult.
Anyone have suggestions on how to restore that functionality so I can just keep my hands on the keyboard?
My Settings
I am using Automator to test this.
In System Preferences &gt; Notifications, I selected Automator:

Allow Notifications is true.
Automator alert style: is Alerts.
Notification grouping is automatic.

Testing

I opened Automator and created a new workflow.
I added three instances of the Display Notification action.
I gave them Title: values of test 1, test 2, and test 3.
And Subtitle: values of subtitle 1, subtitle 2, and subtitle 3.
And Message: values of message 1, message 2, and message 3.
I ran the workflow using ⌘+R.
In the upper-right corner of my screen, I see a notification from Automator stacked over two others. Only notification test 3 is fully visible and it has the notation &quot;2 more notifications&quot; at the bottom.

@AndrewJanian 's Script

Again, thank you, Andrew for providing the script!
I added the line #!/usr/bin/osascript to the start of the script and saved it as andrew.applescript.
I made the file executable. (chmod 755 andrew.applescript).
I ran it in a terminal window (./andrew.applescript)
The result of running is:

the grouped notifications become ungrouped (so I see test 3, test 2, and test 1 stacked top to bottom in the notification area
the terminal displays the following error
./andrew.applescript:370:377: execution error: System Events got an error: Can’t get action &quot;Name:Clear All
Target:0x60000116ff20
Selector:_internal_handleCustomActionWithUiAction:&quot; of group 1 of UI element 1 of scroll area 1 of window &quot;Notification Center&quot; of application process &quot;NotificationCenter&quot;. (-1728)





I'll try messing around with it to see if I can make it work with modifications.
Note: If I run the script again, starting from the ungrouped state:

it dismisses the top-most notification (test 3)
and it displays the following in the terminal:
action Name:Close
Target:0x60000116ff20
Selector:_internal_handleCustomActionWithUiAction: of group 1 of UI element 1 of scroll area 1 of window Notification Center of application process NotificationCenter
Update
I'm posting a most robust version that evolved from my initial post. This seems to do a reasonable job of closing all windows, but it's sometimes slow to execute. As I've stated in the comments, I don't know much about AppleScript, so perhaps someone who knows what they're doing can tell us how to improve the performance.
activate application &quot;NotificationCenter&quot;
tell application &quot;System Events&quot;
    tell process &quot;Notification Center&quot;
        repeat
            
            try
                set theWindow to group 1 of UI element 1 of scroll area 1 of window &quot;Notification Center&quot;
            on error
                exit repeat
            end try
            
            try
                set theActions to actions of theWindow
                
                # Try to close the whole group first. If that fails, close individual windows.
                repeat with theAction in theActions
                    if description of theAction is &quot;Clear All&quot; then
                        set closed to true
                        tell theWindow
                            perform theAction
                        end tell
                        exit repeat
                    end if
                end repeat
                
                repeat with theAction in theActions
                    if description of theAction is &quot;Close&quot; then
                        set closed to true
                        tell theWindow
                            perform theAction
                        end tell
                        exit repeat
                    end if
                end repeat
                
            end try
        end repeat
    end tell
end tell

Original
Yes, thank you for posting the script, @AndrewJanian.
I received an error similar to @ColinFraizer's when using it as is. I think the issue is the inner repeat over the actions: it's trying to access actions in some cases after the window is closed. A minor tweak fixes this issue for me:
activate application &quot;NotificationCenter&quot;
tell application &quot;System Events&quot;
    tell process &quot;Notification Center&quot;
        set theWindow to group 1 of UI element 1 of scroll area 1 of window &quot;Notification Center&quot;
        # click theWindow
        set theActions to actions of theWindow
        repeat with theAction in theActions
            if description of theAction is &quot;Close&quot; then
                tell theWindow
                    perform theAction
                end tell
                exit repeat
            end if
        end repeat
    end tell
end tell