使用 Applescript 取消最小化应用程序

发布于 2024-12-08 17:28:27 字数 600 浏览 0 评论 0 原文

我正在尝试编写一个脚本来取消最小化之前最小化到停靠的应用程序。 问题是,我找不到相关的属性。我尝试过小型化折叠,但窗口和进程似乎都没有这些?

我使用(用于测试)的应用程序是 Zipeg,一个免费的打包​​工具。

我还尝试单击按钮,该按钮可以愉快地最小化应用程序,但在已经最小化的应用程序上运行以恢复它时给我一个错误,可能是因为没有窗口可见。该脚本如下。

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

我用来列出属性的脚本如下。

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

有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

酒浓于脸红 2024-12-15 17:28:27
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

如果未选中最小化窗口到应用程序图标,则这将取消最小化单个窗口:

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

如果应用程序的所有窗口都最小化,重新打开将取消最小化第一个窗口:

tell app "TextEdit"
    reopen -- unminimizes the first minimized window or makes a new default window
    activate -- makes the app frontmost
end tell
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
人疚 2024-12-15 17:28:27

如果您告诉应用程序“App”激活,如果所有窗口都最小化,它将取消最小化窗口。

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

甜中书 2024-12-15 17:28:27

这应该适合你:

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

This should work for you:

tell application "Safari"
    activate
    set index of window 1 to 1
end tell
想你的星星会说话 2024-12-15 17:28:27

尝试沿着这些思路做一些事情。

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

Try something along these lines.

tell application "Finder" to set collapsed of every window to false
悟红尘 2024-12-15 17:28:27

这是一个取消最小化当前聚焦的应用程序先前最小化窗口的脚本。

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

我发现这个脚本比接受的答案更有用。

这个脚本不是我写的,你可以找到更多相关脚本这里

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文