Javascript JXA:使用自定义图标显示对话框
使用AppleScript,我们可以轻松显示带有自定义图标的对话框:Javascript JXA:使用自定义图标显示对话框,javascript,applescript,javascript-automation,Javascript,Applescript,Javascript Automation,使用AppleScript,我们可以轻松显示带有自定义图标的对话框: display dialog "Test" with icon POSIX file "{{path_to_our_icon}}" 我们如何使用JXA(用于自动化的JavaScript)实现同样的功能?这份报告似乎没有涵盖这一点。它只告诉我们如何使用其中一个预定义图标。如果SDEF字典指定file类型的参数,则需要在path()构造函数中包装完整的路径字符串 (有关Path()的更多信息,请参阅JavaScript For
display dialog "Test" with icon POSIX file "{{path_to_our_icon}}"
我们如何使用JXA(用于自动化的JavaScript)实现同样的功能?这份报告似乎没有涵盖这一点。它只告诉我们如何使用其中一个预定义图标。如果SDEF字典指定file类型的参数,则需要在path()构造函数中包装完整的路径字符串 (有关Path()的更多信息,请参阅JavaScript For Automation发行说明中的“路径”下)
当SDEF字典指定file类型的参数时,您需要path()构造函数中包装的完整路径字符串 (有关Path()的更多信息,请参阅JavaScript For Automation发行说明中的“路径”下)
(function () {
'use strict';
var a = Application.currentApplication(),
sa = (a.includeStandardAdditions = true, a);
sa.displayDialog('Test', {
defaultAnswer: 'Next question ?',
buttons: ['OK', 'Cancel'],
defaultButton: 'OK',
cancelButton: 'Cancel',
withTitle: 'Test dialog',
withIcon: Path('/System/Library/Frameworks/Automator.framework/Versions/A/Resources/Automator.icns')
});
})();