通过JavaScript发送Mac OS X的通知中心消息 - 10.10优胜美地 [英] Send Mac OS X Notification Center message via JavaScript - 10.10 Yosemite
问题描述
如何的消息被发送到Mac OS X的使用通知中心的<一个href=\"https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/\"相对=nofollow>这是在10.10介绍JavaScript的自动化功能约塞米蒂?
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?
推荐答案
信息可以通过使用 includeStandardAdditions
方法从被发送到通过的Automator和脚本编辑器中的JavaScript通知中心核心库。例如:
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')
脚本编辑器应用程序的文档,显示他们休息的场所。它可以从窗口 - >库来访问。菜单并选择StandardAdditions图书搜索的displayNotification命令
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.
本例使用的全套方案:
app = Application.currentApplication()
app.includeStandardAdditions = true
app.displayNotification('Advanced message', {
withTitle: 'Message Title',
subtitle: 'Subtitle',
soundName: 'Sosumi'
})
这篇关于通过JavaScript发送Mac OS X的通知中心消息 - 10.10优胜美地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!