Un-minimizing an app with Applescript

二次信任 提交于 2019-12-05 16:14:04

问题


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?


回答1:


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



回答2:


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




回答3:


This should work for you:

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



回答4:


Try something along these lines.

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


来源:https://stackoverflow.com/questions/7681418/un-minimizing-an-app-with-applescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!