使用Applescript最小化应用程序

编程入门 行业动态 更新时间:2024-10-25 04:18:18
本文介绍了使用Applescript最小化应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试编写脚本来取消最小化以前已最小化以停靠的应用程序. 问题是,我找不到相关属性.我已经尝试过miniaturized和collapsed,但是窗口或进程似乎都没有这些?

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?

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

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

有什么想法吗?

推荐答案

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

如果将应用程序的所有窗口最小化,则reopen将使第一个窗口最小化:

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

更多推荐

使用Applescript最小化应用程序

本文发布于:2023-11-04 05:21:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557055.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最小化   应用程序   Applescript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!