我正在使用 OS X JavaScript for Automation (JXA),并且我希望能够捕获“开放位置”Apple 事件。
根据http://www.macosxautomation.com/applescript/linktrigger/,我设置了一个客户 URL 处理程序。我该怎么做
on open location this_URL
...
end open location
与 JXA?我尝试了以下所有方法,但无法执行它们中的任何一个:
app = Application.currentApplication();
app.includeStandardAdditions = true;
function run() {
app.displayDialog(JSON.stringify(arguments));
}
function openLocation() {
app.displayDialog(JSON.stringify(arguments));
}
function openDocuments() {
app.displayDialog(JSON.stringify(arguments));
}
function onOpenLocation() {
app.displayDialog(JSON.stringify(arguments));
}
Apple 的 JXA 文档(https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/Articles/OSX10-10.html#//apple_ref/doc/uid/TP40014508-CH109-SW15)不要t 讨论如何处理开放位置事件。我的脚本会被打开,因为如果我将它添加到函数之外,我会得到一个显示的警报。我只是无法获得执行并在 URL 中传递的函数。
我正在通过一个 AppleScript 处理程序来解决这个问题,该处理程序然后调用我的 JXA 代码,但这肯定不太理想。
我也没有在 JXA Cookbook ( https://github.com/dtinth/JXA-Cookbook ) 中看到任何关于此的内容。