運行我的一些腳本後,我碰巧遇到了一堆有「無標題」窗口的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
什麼可能是錯誤的?