OSX Mavericks - keyboard shortcut to kill notifications
This used to work:
tell application "System Events"
tell process "NotificationCenter"
click at {2500, 50}
end tell
end tell
But in Mavericks it gives me "System Events got an error: Can’t make {2500, 50} into type list." I finally found a fix, though:
tell application "System Events"
tell process "NotificationCenter"
click button "Close" of window 1
end tell
end tell
That closes the bottommost notification, which is good enough for me.
Also handy is this script to nuke 'em all:
tell application "System Events"
tell process "NotificationCenter"
set numwins to (count windows)
repeat with i from numwins to 1 by -1
click button "Close" of window i
end repeat
end tell
end tell
You can use a script like this to click a notification:
tell application "System Events" to click window 1 of process "NotificationCenter"
It closes both banner and alert notifications that don't have a default action, but it performs the default action (like opening App Store for the "OS X Updates Available" notifications) if a notification has a default action.