0

Is there an apple script that can click on the notification for me so that I don't have to open the app using a mouse?

I plan to bind this script to a keyboard shortcut and that way I can open incoming notifications with just the keyboard.

Here are two notifications type examples

enter image description here

enter image description here

Note that scripts like this wont work because it attempts to click on a button and there's no consistent button to click on to open a notification. Sometimes its top, sometimes its bottom, sometimes its neither.

What is needed is a script that clicks on the "left" part of the notification, that will always open the app.

1
  • Added the details
    – erotsppa
    Apr 20, 2020 at 22:40

1 Answer 1

1

Testing under macOS High Sierra, the following line of example AppleScript code, when run, had the following general effects on a notification:

tell application "System Events" to ¬
    click every window of application process "Notification Center"
  • Open the app for which the notification was from, if it wasn't already opened.
  • If the app was already open, it would set focus to the app.
  • If notification from multiple apps, the app on the top notification in the list gets opened/focus, additions apps get opened, if not already open.

Note that with some notifications, they will be dismissed; however, with others, the app will still be opened/focused as applicable but the notification will not be dismissed. These will need to be replied to appropriately.

1
  • Looks like this is now broken in big sur, and instead open the notifciations center. Any solution?
    – erotsppa
    Feb 5, 2021 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .