Keyboard control of Big Sur notification alerts
With the release of Big Sur, my scripts for keyboard control of macOS notification alerts stopped working. With a bit of experimentation and help from Google, I have written new ones. Closing an alert To close a notification alert on Big Sur, conceptually we want to press the X button that appears when you hover over it. The AppleScript to do this is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
activate application "NotificationCenter" tell application "System Events" tell process "NotificationCenter" set theWindow to group 1 of UI element 1 of scroll area 1 of window "Notification Center" # click theWindow set theActions to actions of theWindow repeat with theAction in theActions if description of theAction is "Close" then tell theWindow perform theAction end tell exit repeat end if end repeat end tell end tell |
This is much more complicated than just clicking button 1 of… continue reading.