gpt4 book ai didi

macos - 如何使用 JXA 关闭所有 Finder 窗口

转载 作者:行者123 更新时间:2023-12-01 08:54:43 28 4
gpt4 key购买 nike

我基本上想将此代码从 AS 移植到 JXA:

tell application "Finder"
close every window
open folder "Projects" of folder "Documents" of home
tell the front Finder window
set the bounds to {0, 0, 1920, 1080}
set the current view to list view
end tell
end tell

提前致谢!关于 JXA 的信息太少了!

最佳答案

要关闭所有 Finder 窗口,脚本需要循环:

finder.finderWindows().forEach(function(w) {w.close()})

var allWindows = finder.finderWindows()
for (var i in allWindows) {allWindows[i].close()}

或者使用ma​​p方法:

var finder = Application('Finder')
finder.finderWindows().map(function(w){w.close()})
finder.home.folders["Documents"].folders["Projects"].open()
finder.finderWindows[0].bounds = {"x":0, "y":0, "width":1920, "height":1000}
finder.finderWindows[0].currentView = 'list view'

关于macos - 如何使用 JXA 关闭所有 Finder 窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35285851/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com