在 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)
}
我不确定你需要 cocoa 。您可能需要标准库。
关于javascript - 使用 javascript 而不是 applescript 的邮件规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49117223/