2014-01-17 65 views
5

如何在AppleScript中打開Finder的新窗口?我正在使用if else語句來打開一個窗口。我嘗試了一個Osascript命令,但它給了我一個語法錯誤。代碼如下:使用AppleScript打開新的Finder窗口

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 

回答

7

嘗試:

tell application "Finder" to make new Finder window 
+0

做得好; OSX 10.11.4有兩個怪癖。 (a)奇怪的是,以這種方式創建的窗口不會顯示在「窗口」菜單中。 (b)新窗口的「目標」(即位置)始終是整個計算機的設備視圖,而不管Finder首選項中配置了什麼。此外,看起來'具有屬性{target:...}'會被忽略 - 你知道一種指定目標位置的方法嗎(除了設置_later_,這在視覺上是破壞性的)嗎? – mklement0