我不知道如何使用AppleScript,我如何让我的小bash脚本首先工作在我之外.我目前正在使用AppleScript来运行我的bash脚本,它的工作非常棒.它在下面.
do shell script "/Users/john/Scripts/screenshot -i --delete"
Run Code Online (Sandbox Code Playgroud)
现在它引用的bash脚本是它将截取屏幕截图并将其上传到我的服务器;
我希望它在完成时播放声音,我该怎么做呢?AppleScript超出我的知识......
ada*_*amh 19
你可以使用afplay:
do shell script "afplay /Users/john/Sounds/vengabus.aiff"
Run Code Online (Sandbox Code Playgroud)
或者我喜欢用文字说话:
say "Finished!"
Run Code Online (Sandbox Code Playgroud)
小智 9
通知中心(可能仅限OS X 10.9.x)可以显示带声音的消息.
set variableWithSoundName to "Glass"
display notification "Upload complete" with title "Screenshot" subtitle "Status" sound name variableWithSoundName
-- "sound name" is the name of a sound located in "~/Library/Sounds"
-- or "/System/Library/Sounds"
Run Code Online (Sandbox Code Playgroud)
的display notification命令是从所述StandardAdditions.
(...并且还有一个命令beep可以播放默认的警报声并将"哔哔"的数量作为参数)
只是为了补充@adamh和@DigiMonk的优秀答案:
beep如果默认声音会这样做,那么老年人可以胜任:
beep # beep once
Run Code Online (Sandbox Code Playgroud)
如果一次还不够,只需指定所需的哔声数作为参数:
beep 2 # beep twice.
Run Code Online (Sandbox Code Playgroud)
顺便说一句,beep,say,并且display notification都在定义User Interaction套件字典StandardAdditions.sdef.要查看这些定义,请File > Open Dictionary...在AppleScript编辑器中选择,然后在弹出的列表中选择StandardAdditions.osax.