运行我的一些脚本后,我碰巧遇到了一堆有“无标题”窗口的Safari窗口。使用applescript关闭多个Safari窗口
我想出了以下代码来关闭所有具有“Unitlted”作为名称的窗口,但它没有关闭所有包含错误消息的所有窗口 - >“Safari出现错误:无法获取项目9的每一个窗口,索引无效“。我必须多次运行才能关闭所有窗口。
tell application "Safari"
repeat with w in windows
if name of w is "Untitled" then
tell w to close
end if
end repeat
end tell
什么可能是错误的?