-
Notifications
You must be signed in to change notification settings - Fork 1
/
dismiss-os12-and-earlier.scpt
50 lines (40 loc) · 1.06 KB
/
dismiss-os12-and-earlier.scpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
tell application "System Events"
set frontmostApplicationName to name of 1st process whose frontmost is true
end tell
activate application "NotificationCenter"
tell application "System Events"
tell process "Notification Center"
repeat
try
set theWindow to group 1 of UI element 1 of scroll area 1 of window "Notification Center"
on error
exit repeat
end try
try
set theActions to actions of theWindow
# Try to close the whole group first. If that fails, close individual windows.
repeat with theAction in theActions
if description of theAction is "Clear All" then
set closed to true
tell theWindow
perform theAction
end tell
exit repeat
end if
end repeat
repeat with theAction in theActions
if description of theAction is "Close" then
set closed to true
tell theWindow
perform theAction
end tell
exit repeat
end if
end repeat
end try
end repeat
end tell
end tell
tell application frontmostApplicationName
activate
end tell