使用AppleScript打开新的Finder窗口

7
如何在AppleScript中打开一个新的Finder窗口?我使用if else语句来打开一个窗口。我尝试使用Osascript命令,但它给了我一个语法错误。以下是代码:
if the button returned of the result is "Sleep" then
    tell app "Finder" to go to sleep
if the button returned of the result is "Open Finder" then
    osascript -e 'tell application "Finder" to open new window'
else
    display dialog current time
end if
2个回答

13

尝试:

tell application "Finder" to make new Finder window

1
做得很好;截至OSX 10.11.4,有两个小问题。 (a) 奇怪的是,以这种方式创建的窗口不会显示在“窗口”菜单中。 (b) 新窗口的“目标”(即位置)始终是整个计算机的设备视图,而不管Finder首选项中配置了什么。此外,似乎忽略了“with properties {target:...}”-您知道指定目标位置的方法吗(除了稍后设置它,这会对视觉造成干扰)? - mklement0

-1

我的 Alfred 工作流脚本:

on alfred_script(q)
    tell application "Finder"
        make new Finder window
    end tell
end alfred_script

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接