在Mac邮件规则中,我试图运行javascript而不是AppleScript。有人问过Mail Rules using JavaScript for Automation instead of AppleScript,但答案对我不起作用!
我尽可能地尝试简化代码。所以,以下的AppleScript工作正常:
on perform mail action with messages theMessages
say "running!"
end perform mail action with messages
但是等效的javascript无效。
function performMailActionWithMessages(messages) {
app = Application.currentApplication()
app.includeStandardAdditions = true
app.say ("running")
}
编辑这是我的规则参数
我没有得到应用程序。试试像......
// ObjC.import('Cocoa')
ObjC.import('stdlib')
var program="/usr/bin/say"
function performMailActionWithMessages(messages) {
say("running")
}
function say(what){
var command = program + " '"+what+"'"
console.log(command)
$.system(command)
}
我不确定你需要可可。你可能需要stdlib。