Kill Notifications in OS X with KBM?

I have a KBM macro that triggers an Apple Script to kill notifications, which works some of the time but often requires several taps (repeats) and sometimes gives me error messages. Here's the trigger-macro:

Here's the script it triggers:

Is there a more efficient way to do this right out of KBM? I didn't see anything listed in this forum.

Many thanks.

I wonder if it would be easier to take another route? Such as trying to control the notification centers “Do Not Disturb” system preference panel?

Might be, but I do want the notifications to appear. I just want to dismiss them when they pile up (in the morning I get 4 or 5 from my calendars all at once—I should have clarified that). tx

I wonder if there isn't a way to do this by opening the Activity Monitor, locating "Notification Center", and commanding it to quit. Currently stuck at clicking on the item but I think this should work.

That looks like it would probably work if the windows size doesn’t change. I guess I am not the only one who finds notification center annoying. Heh!

Take a look at this:
Should be what you’re searching for.
@Tunes You can resize coming up apps windows etc with keyboard maestro, so that you wouldn’t have to worry about it :slight_smile:

1 Like

Fantastic. Problem solved. My only comment is: “Uncle”. I give up, and will leave scripting to the experts! thanks for locating this. It’s much better than the Apple Script that I had earlier found. Thank goodness he put it into KBM format for the rest of us innocents.

Good tip on using JS to handle the notifications. Is the code complete on Ryan’s page or would I have to add additional code?

Now If I could just locate an AppleScript that allows me to take an MBOX file and convert it to csv and handles the attachment to import into Filemaker Pro. :wink: Been looking for the last couple of days.

Yep, it’s complete! :slight_smile: I use it all the time and has worked without problems.

It also intentionally ignores notifications that don’t have a “Close” or “OK” button to prevent bad things from happening like running system updates when you don’t want them to.

1 Like

Ryan, thanks for sharing this great macro.
Would you mind posting it in the "macro" sub-forum so it will be easy to find for everyone?

So Ryan, just to be clear. I write a Keyboard Maestro Macro macro including a JavaScript action with the following:

var app = Application("System Events")

notificationCenter = app.processes.byName('NotificationCenter')

function closeWindow(window){
_or: [
{name: "Close"},
{name: "OK"}

Is that correct?

If you read the entire post, at the very bottom is a KM macro that you can download and use. No work required!

Ah! But in order to grow, it’s the work that’s important!! :smile: