2011-10-06 79 views
7

我正在嘗試編寫腳本以取消最小化以前最小化的應用程序以停靠。 問題是,我無法找到相關的屬性。我試過miniaturizedcollapsed,但窗口和過程似乎都沒有?取消最小化Applescript的應用程序

我使用(測試)的應用程序是Zipeg,一個免費的打包​​工具。

我也試着點擊那個愉快地使應用程序最小化的按鈕,但是在已經最小化的應用程序上運行來恢復它的時候給我一個錯誤,可能是因爲沒有窗口可見。這個腳本如下。

tell application "System Events" 
    tell process "Zipeg" 
     click button 1 of window 1 
    end tell 
end tell 

我用來列出屬性的腳本如下。

tell application "System Events" 
    tell process "Zipeg" 
     get properties 
     tell window 1 
      get properties 
     end tell 
    end tell 
end tell 

任何想法?

回答

9
tell app (path to frontmost application as text) 
    try 
     set miniaturized of windows to false -- most apps 
    end try 
    try 
     set collapsed of windows to false -- Finder 
    end try 
end tell 

這unminimizes單個窗口如果最小化窗口到應用程序圖標未選中:

try 
    tell app "System Events" to tell process "Dock" 
     click (last UI element of list 1 where role description is "minimized window dock item") 
    end tell 
end try 

如果某個應用的所有窗口被最小化,reopen unminimizes第一個:

tell app "TextEdit" 
    reopen -- unminimizes the first minimized window or makes a new default window 
    activate -- makes the app frontmost 
end tell 
+0

重新開放是我waas尋找。謝謝! – rickythefox

0

如果你tell application "App" to activate如果所有窗口都被最小化,它將不會最小化一個窗口。

+0

不,不適用於應用程序。也嘗試與iTunes(告訴應用程序「iTunes」激活),並不在那裏工作...它激活並顯示應用程序的菜單,但沒有窗口。 – rickythefox

+0

嗯......它沒有。我認爲「激活」應該等同於點擊Dock圖標。 – CajunLuke

+0

@CajunLune'reopen'相當於點擊Dock圖標。如果沒有打開的窗口,它會取消最小化第一個窗口或創建一個新的默認窗口。 – user495470

0

這應該爲你工作:

tell application "Safari" 
    activate 
    set index of window 1 to 1 
end tell 
0

嘗試沿着這些路線的東西。

tell application "Finder" to set collapsed of every window to false 
+0

正如我上面寫的那樣,問題窗口沒有「摺疊」屬性。上面的代碼適用於Finder,但我的應用程序有另一組屬性。 – rickythefox