OSX Mavericks - 取消通知的键盘快捷键

lio*_*man 7 keyboard-shortcuts notifications osx-mavericks

是否可以在 OSX Mavericks 中创建键盘快捷键来杀死/隐藏通知中心警报(并加速隐藏一段时间后自动消失的横幅)?

编辑:我使用了 Terry 的“nuke all”AppleScript(如果通知不存在,它的额外好处是不会抛出错误),保存到 Documents 并编译,然后将其移动到 Library/Scripts/ 并下载FastScripts的免费副本到分配键盘快捷键。

Ter*_*rry 8

曾经有效:

tell application "System Events"
    tell process "NotificationCenter"
        click at {2500, 50}
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)

但是在小牛队中,它给了我“系统事件出错:无法将 {2500, 50} 放入类型列表。” 不过,我终于找到了解决办法:

tell application "System Events"
    tell process "NotificationCenter"
       click button "Close" of window 1
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)

这关闭了最底层的通知,这对我来说已经足够了。

这个脚本也很方便:

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
Run Code Online (Sandbox Code Playgroud)