如何最大化最小化的 window(applescript 不适用于从 Capitan 升级到 Mojave)

How to unminimize a minimized window (apple script not working with upgrade from Capitan to Mojave)

我有一个为 El Capitan 编写的脚本,升级到 mojave 它停止工作。有没有办法让 unminimize 最近的 window 回来?这是我之前使用的脚本:

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

你的脚本似乎工作正常,但我已经用一些条件和错误检查来欺骗它,使任何问题更容易诊断和管理。

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

编辑

根据评论:正如我所说,我并没有真正更改代码,我只是添加了错误检查。要一次打开所有最小化的 window,请使用 try 块中已有的代码。即:

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