2013-04-28 45 views
0

我正在構建一個更復雜的applescript,但我想先弄清楚基礎知識。爲什麼這個蘋果腳本打開safari隱藏?

tell application "Safari" 
activate 
end tell 

tell application "System Events" 
    tell process "Safari" 
     tell menu bar 1 
      tell menu bar item "File" 
       tell menu "File" 
        click menu item "New Window" 
       end tell 
      end tell 
     end tell 
    end tell 
end tell 

我似乎無法弄清楚的問題是爲什麼當我運行它時,safari被打開爲隱藏狀態。

回答

1

當我運行腳本時,新窗口不會隱藏。

試試這個:

tell application "Safari" to make new document 
+0

與此並將激活命令移動到最後,它現在工作,謝謝! – Andrew 2013-04-28 19:32:40

1

它沒有打開Safari瀏覽器隱藏了我。但打開Safari瀏覽器背後的其他應用程序,如果它尚未運行,直到我說set frontmost to true到最後。

activate application "Safari" 
tell application "System Events" to tell process "Safari" 
    click menu item "New Window" of menu 1 of menu bar item 3 of menu bar 1 
    set frontmost to true 
end tell 

您也可以嘗試使用reopen。如果沒有可見的窗口或只有例如首選項窗口可見,或者如果所有默認窗口都被最小化,它會打開一個新的默認窗口,它會取消其中一個窗口的最小化。

tell application "Safari" 
    activate 
    reopen 
end tell 
+0

我能用另一種方法解決我的問題,但這些建議都很好 – Andrew 2013-05-01 19:33:52

相關問題