Created
January 3, 2017 05:56
-
-
Save Down10/8313be11b45da69e8ae7826daec575f9 to your computer and use it in GitHub Desktop.
Close all of the annoying mac OS notification windows at once! Just make a new service routine in Automator, pick "Run Applescript" with `no input` in `any application`, paste in this script, and save as a Service. Then apply a keystroke and enjoy!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {} | |
if isNotificationCenterRunning() then | |
my closeAllNotes() | |
end if | |
end run | |
on closeAllNotes() | |
tell application "System Events" | |
tell application process "NotificationCenter" | |
set everyNote to every window | |
set noteCount to (count everyNote) | |
if noteCount > 0 then | |
repeat with thisNote in everyNote | |
try | |
tell thisNote | |
click button 1 -- "Close" in most cases | |
end tell | |
on error | |
if noteCount > 0 then | |
my closeAllNotes() -- Try it again | |
else | |
exit repeat | |
end if | |
end try | |
end repeat | |
end if | |
end tell | |
end tell | |
end closeAllNotes | |
on isNotificationCenterRunning() | |
set isRunning to false | |
tell application "System Events" | |
set isRunning to (name of every application process) contains "NotificationCenter" | |
end tell | |
isRunning | |
end isNotificationCenterRunning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment