audio - applescript play random sound when pressing cmd + enter -
i'm looking play random sound set of sound clips in folder when press cmd + enter. applescript running , whenever user presses cmd + enter random sound (mp3) played without opening itunes, preferably behind scenes.
thanks!
i didn't know afplay
, that, simple script it:
property soundsdirectory : posix file "/path/to/sounds/" alias tell application "system events" ¬ set soundfile posix path of (some item of soundsdirectory alias) shell script "afplay " & quoted form of soundfile
if have classic mac path of form macintosh hd:users:you:sounds:
, can use property soundsdirectory : alias "macintosh hd:users:you:sounds:"
instead, either work. some item of <list>
command returns random item list; have promise applescript alias as alias
can unix-style path out of it. quoted form of <text>
command puts text in single quotes (while escaping single quotes) use in shell; afplay
plays it.
for ⌘↩ requirement, i'd use spark, although there number of options. spark runs in background , lets execute applescript on keyboard shortcut, among other things. don't know way have applescript running, fast enough start shouldn't issue. you'll have spark running instead.
Comments
Post a Comment