17

I'm trying to write a script to un-minimize an app that was previously minimized to dock. Problem is, I can't find the relevant property. I've tried miniaturized and collapsed but neither the window nor the process seems to have those?

The app I use (for testing) is Zipeg, a free packing tool.

I've also tried to click the button which happily MINIMIZES the app, but gives me an error when running on an already minimized app to restore it, probably because no window is visible. This script is below.

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

The script I used to list properties is below.

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

Any ideas?

rickythefox
  • 6,601
  • 6
  • 40
  • 62

5 Answers5

20
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

This unminimizes a single window if Minimize windows into application icon isn't checked:

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

If all windows of an app are minimized, reopen unminimizes the first one:

tell app "TextEdit"
    reopen -- unminimizes the first minimized window or makes a new default window
    activate -- makes the app frontmost
end tell
Lri
  • 26,768
  • 8
  • 84
  • 82
1

if you tell application "App" to activate it will un-minimize a window if all windows are minimized.

Cajunluke
  • 3,103
  • 28
  • 28
  • 2
    Nope, does not work for the app. Also tried with ITunes (tell application "iTunes" to activate) and doesn't work there either... It activates and shows the application's menu, but no window. – rickythefox Oct 06 '11 at 23:02
  • Hmmm… it doesn't. I thought `activate` was supposed to be equivalent to clicking on the Dock icon. – Cajunluke Oct 06 '11 at 23:05
  • 1
    @CajunLune `reopen` is the equivalent of clicking a Dock icon. If there's no open windows, it unminimizes the first minimized window or makes a new default window. – Lri Oct 07 '11 at 12:12
  • @Lri your comment solved my problem and should definitely be an answer... – Kubuntuer82 May 03 '20 at 15:14
0

This is a script that un-minimizes the previously minimized window of the currently focused application.

tell application id ("com.apple.systemevents")  ¬
  to tell (process 1 where it is frontmost) ¬
  to tell (windows whose attribute named "AXMinimized"'s value is true) ¬
  to if (it exists) then set the value of its attribute named "AXMinimized" of item 1 to false

I found this script more useful than the accepted answer.

This script is not written by me, and you can find more related scripts here.

Sanghyun Lee
  • 21,644
  • 19
  • 100
  • 126
0

This should work for you:

tell application "Safari"
    activate
    set index of window 1 to 1
end tell
eykanal
  • 26,437
  • 19
  • 82
  • 113
0

Try something along these lines.

tell application "Finder" to set collapsed of every window to false
fireshadow52
  • 6,298
  • 2
  • 30
  • 46
  • As I wrote above, the window in question has no "collapsed" property. The code above works for Finder but my app has another set of properties. – rickythefox Oct 07 '11 at 06:47