macos - 如何取消最小化最小化窗口(苹果脚本不适用于从 Capitan 升级到 Mojave)
问题描述
我有一个为 El Capitan 编写的脚本,升级到 mojave 它停止工作。有没有办法让最近的窗口最小化?这是我以前使用的脚本:
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
编辑
根据评论:正如我所说,我并没有真正更改代码,我只是添加了错误检查。要一次打开所有最小化的窗口,请使用 try 块中已有的代码。IE:
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
推荐阅读
- php - 如何在php中选择sql查询的第n行
- javascript - 如何使用 ReactDOM.render 改变 DOM 元素?
- javascript - 单击一次后,我想禁用单击属性
- arrays - 实时视频到阵列
- asp.net-core - 如何在.net Core后面的代码中更改元素的样式
- flutter - 如何在颤动的数据表中执行搜索功能?
- python - 可重用的 SQL 示例连接字符串
- sql - 按列 ID SQL 制作重复的行号
- javascript - H.geo.LineString 的行为不像 h.geo.strip
- react-native - 如何从反应本机表单中输入字段旁边的按钮选择文件。(请参阅图片以更好地理解)