如何最小化最小化窗口(Apple脚本不适用于从Capitan到Mojave的升级)

时间:2019-08-08 12:21:48

标签: macos applescript macos-mojave appleevents

我有一个为El Capitan编写的脚本,该脚本升级到莫哈韦沙漠时停止工作。有没有办法使最近窗口最小化?这是我以前使用的脚本:

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

1 个答案:

答案 0 :(得分:0)

您的脚本似乎可以正常工作,但是我通过一些条件和错误检查将其欺骗了,以使任何问题的诊断和管理都更加容易。

    {!! Form::open(['action' => "LA\'$create->controller'@store", 'id' => 'customer-add-form']) !!}

编辑

每个注释:正如我所说,我并没有真正更改代码,只是添加了错误检查。要一次打开所有最小化的窗口,请使用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