0
使用JavaScript进行自动化时,发现自己无法在AppleScript中执行非常简单的操作。 (令人震惊的,我知道。)使用JavaScript for Automation取消选择Finder中的全部
这个的AppleScript:
tell application "Finder" to set selection to {}
清除在Finder中选择。
我只是无法弄清楚如何在JXA中做同样的事情。
这是我已经试过:
var finder = Application("Finder")
finder.includeStandardAdditions = true
//this selects files in the front window...
finder.select([...array of file paths...])
//so you'd think this might work to deselect all...
finder.select([])
//...but it doesn't do anything
//then I tried each of these in turn...
finder.select(null)
//Error -10010: Handler can't handle objects of this class.
finder.selection = null
//Error -10010: Handler can't handle objects of this class.
finder.selection = []
//Script Editor crashes
//...but none were successful
有什么建议?
(MacOS的塞拉利昂,脚本编辑器2.9)
是的,你的第二个解决方案就是我最终的目标。像这样的混合可能不是最优雅的,但它比关闭和重新打开窗户更好。谢谢! –