问题
How can a message be sent to the Mac OS X Notification Center using the JavaScript for Automation functionality that was introduced in 10.10 Yosemite?
回答1:
Messages can be sent to Notification Center via Automator and Script Editor JavaScripts by using the includeStandardAdditions
method from the core library. For example:
app = Application.currentApplication()
app.includeStandardAdditions = true
app.displayNotification('Basic message')
The Script Editor application has documentation that shows they rest of the options. It can be accessed from the "Window -> Library" Menu and choosing the "StandardAdditions" Library and searching for the "displayNotification" command.
This example uses the full set of options:
app = Application.currentApplication()
app.includeStandardAdditions = true
app.displayNotification('Advanced message', {
withTitle: 'Message Title',
subtitle: 'Subtitle',
soundName: 'Sosumi'
})
来源:https://stackoverflow.com/questions/27414831/send-mac-os-x-notification-center-message-via-javascript-10-10-yosemite