big*_*lep 6 macos applescript automation javascript-automation
我正在使用OS X JavaScript for Automation(JXA),我希望能够捕获"开放位置"的Apple Event.
根据http://www.macosxautomation.com/applescript/linktrigger/,我设置了一个客户URL处理程序.我该怎么做相同的
on open location this_URL
...
end open location
Run Code Online (Sandbox Code Playgroud)
与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));
}
Run Code Online (Sandbox Code Playgroud)
Apple的JXA文档(https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/Articles/OSX10-10.html#//apple_ref/doc/uid/TP40014508-CH109-SW15)don '讨论如何处理开放位置事件.我的脚本将被打开,因为如果我将其添加到函数之外,我可以显示警告.我只是无法获得一个函数来执行并在URL中传递.
我正在通过使用AppleScript处理程序来解决这个问题,然后调用我的JXA代码,但这肯定不太理想.
我也没有在JXA Cookbook(https://github.com/dtinth/JXA-Cookbook)中看到任何相关内容.
正如您所建议的,技巧(目前)似乎是将控制立即传递给同一包中的第二个(用于自动化的 JavaScript)脚本。
on open location strURL
run script (path to resource "jsHandler.scpt" in directory "Scripts") with parameters {{|URL|:strURL}}
end open location
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1067 次 |
最近记录: |