Applescript 等到模态消失

Applescript wait till a modal disappear

我正在编写一个脚本来为很多邮件生成 PDF。因为PDF生成需要一些时间,我希望脚本等到

消失在邮件中。这样我就可以开始处理下一个了。以下是该元素的属性。

既然没有标题,如何指定等到这个元素消失?

你需要两个重复循环,一个等到 sheet 出现,另一个等到 sheet 消失。

tell application "System Events"
    tell process "Mail"
        repeat until exists sheet 1 of window 1
            delay 0.5
        end repeat
        repeat while exists sheet 1 of window 1
            delay 0.5
        end repeat
        -- sheet was dismissed
    end tell
end tell