-1

I have a script written for El Capitan that upgrading to mojave it stopped working. Is there a way to get the unminimize the most recent window back? Here is the previous script I used:

try
    tell application "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
J Spen
  • 2,614
  • 4
  • 26
  • 41

1 Answers1

0

Your script seems to work fine, but I've tricked it out with some conditions and error checking to make any problems a bit easier to diagnose and manage.

tell application "System Events"
    tell process "Dock"
        tell list 1
            try
                set minimizedWindows to every UI element whose role description is "minimized window dock item"
                if minimizedWindows is not {} then
                    click last item of minimizedWindows
                else
                    say "No minimized windows" volume 0.5 without waiting until completion
                end if
            on error errstr
                display alert errstr
            end try
        end tell
    end tell
end tell

EDIT

Per comments: as I said, I didn't really change the code, I merely added error-checking. To open all minimized window at once, use the code you already have inside the try block. i.e.:

tell application "System Events"
    tell process "Dock"
        tell list 1
            try
                set minimizedWindows to every UI element whose role description is "minimized window dock item"
                if minimizedWindows is not {} then
                    click (every UI element whose role description is "minimized window dock item")
                else
                    say "No minimized windows" volume 0.25 without waiting until completion
                end if
            on error errstr
                display alert errstr
            end try
        end tell
    end tell
end tell
J Spen
  • 2,614
  • 4
  • 26
  • 41
Ted Wrigley
  • 2,921
  • 2
  • 7
  • 17
  • Yeah, this still doesn't work for me. Even checked and unchecked the minimized window button in the dock system preferences. Is there an easy way to list or check all the role descriptions as maybe it isn't matching "minimized window dock item" for some reason. I just don't know apple scripts well, but good work on the say command. Nice addition +1 – J Spen Aug 09 '19 at 08:58
  • The script works without an error. Just says no minimized windows so it is an empty list. Also, I have another script that unminimizes all windows which also isn't working. – J Spen Aug 09 '19 at 09:04
  • I figured it out using the accessibility selector. I guess when I upgraded it switched to a different default language for English so it was minimised and not minimized. For anyone that might have an issue. – J Spen Aug 09 '19 at 14:49
  • How do I modify the `click last item of minimizedWindows` to click all minimized windows. I had two scripts: one that just did the last window and one that clicked all of them. Before it was, `click (UI elements of list 1 where role description is "minimized window dock item")`. Then I will accept your answer. – J Spen Aug 09 '19 at 15:07
  • How do you revert this? – mjs Oct 04 '22 at 17:05
  • Meaning minimize all. – mjs Oct 04 '22 at 17:05