使用 javascript 而不是 applescript 的邮件规则 [英] Mail Rules with javascript instead of applescript
本文介绍了使用 javascript 而不是 applescript 的邮件规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Mac 邮件规则中,我试图运行 javascript 而不是 applescript.这已在
解决方案
我没有得到应用程序.尝试类似……
//ObjC.import('Cocoa')ObjC.import('stdlib')var program="/usr/bin/say"函数 performMailActionWithMessages(messages) {说(运行")}功能说(什么){var 命令 = 程序 + "'"+what+"'"控制台日志(命令)$.system(命令)}
我不确定您是否需要可可.您可能需要 stdlib.
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!
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
but the equivalent javascript is not working.
function performMailActionWithMessages(messages) {
app = Application.currentApplication()
app.includeStandardAdditions = true
app.say ("running")
}
Edit Here are my rule parameters
解决方案
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)
}
I’m not sure you need cocoa. You probably need stdlib.
这篇关于使用 javascript 而不是 applescript 的邮件规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文