首页 > 解决方案 > 如何让applescript不等待音效完成?

问题描述

我希望我的脚本同时显示一条消息并播放声音。现在它播放声音,然后显示消息。

do shell script "afplay '/System/Library/Sounds/Morse.aiff'"
display dialog "Could not find contact: " & "\"" & victim & "\"" with icon stop

我怎样才能解决这个问题?

标签: applescript

解决方案


您可以通过重定向和丢弃stderr来做到这一点stdoutstdout

do shell script "afplay /System/Library/Sounds/Morse.aiff >/dev/null 2>&1 &"

注意:如果路径不包含空格,则不需要在单引号中扭曲路径。


推荐阅读