使用javascript而不是applescript的邮件规则 [英] Mail Rules with javascript instead of applescript
本文介绍了使用javascript而不是applescript的邮件规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Mac邮件规则中,我正在尝试运行JavaScript而不是applescript.在使用JavaScript for Automation而不是AppleScript的邮件规则中已对此要求但答案对我不起作用!
In a Mac mail rule, I am trying to run a javascript instead of an applescript. This has been asked in Mail Rules using JavaScript for Automation instead of AppleScript but the answer is not working for me!
我已经尽力简化了代码.因此,以下applescript可以正常工作:
I have tried to simplify the code as much as I can. So, the following applescript works fine:
on perform mail action with messages theMessages
say "running!"
end perform mail action with messages
但等效的javascript无法正常工作.
but the equivalent javascript is not working.
function performMailActionWithMessages(messages) {
app = Application.currentApplication()
app.includeStandardAdditions = true
app.say ("running")
}
修改 这是我的规则参数
推荐答案
我这样做没有应用程序.尝试类似的东西……
I do it without getting app. Try something like…
// 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.
I’m not sure you need cocoa. You probably need stdlib.
这篇关于使用javascript而不是applescript的邮件规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文