Re: beep
Re: beep
- Subject: Re: beep
- From: Tommy Bollman <email@hidden>
- Date: Fri, 29 Apr 2011 22:36:06 +0200
Here is another variation
do shell script "afplay " & quoted form of ("/System/Library/Sounds/" & (some item in {"Basso.aiff", "Blow.aiff", "Bottle.aiff", "Frog.aiff", "Funk.aiff", "Hero.aiff", "Glass.aiff", "Morse.aiff", "Ping.aiff", "Pop.aiff", "Purr.aiff", "Sosumi.aiff", "Submarine.aiff", "Tink.aiff"}))
set mySounds to makeSoundsTable()
set soundCount to count mySounds
(*
repeat with i from 1 to soundCount
repeat with j from 1 to soundCount
do shell script "afplay " & item i of mySounds
do
shell script "afplay " & item i of mySounds
do shell script "afplay " & item j of mySounds
display dialog "sounds " giving up after 5
end repeat
end repeat
*)
-- 2 equal with one different at the end.
repeat with i from 1 to soundCount
ignoring application responses
do shell script "(/usr/bin/afplay " & item i of mySounds & "; /usr/bin/afplay " & item i of mySounds & ") &"
end ignoring
-- do shell script "afplay " & item i of mySounds & " &"
-- do shell script "afplay " & item j of mySounds & " &"
display dialog "sounds " giving up after 5
end repeat
(*
repeat with i from 6 to soundCount
repeat with j from 1 to soundCount
ignoring application responses
do shell script "(/usr/bin/afplay " & item i of mySounds & "; /usr/bin/afplay " & item i of mySounds & " ; /usr/bin/afplay " & item j of mySounds & ") &"
end ignoring
-- do shell script "afplay " & item i of mySounds & " &"
-- do shell script "afplay " & item j of mySounds & " &"
display dialog "sounds " giving up after 5
end repeat
end repeat
*)
on LogMessage(Msg)
do shell script "/usr/bin/logger -t TomsScripts " & quoted form of Msg
end LogMessage
on makeSoundsTable()
set soundList to {}
repeat with aSoundFile in {"Basso.aiff", "Blow.aiff", "Bottle.aiff", "Frog.aiff", "Funk.aiff", "Hero.aiff", "Glass.aiff", "Morse.aiff", "Ping.aiff", "Pop.aiff", "Purr.aiff", "Sosumi.aiff", "Submarine.aiff", "Tink.aiff"}
set end of soundList to quoted form of ("/System/Library/Sounds/" & contents of aSoundFile)
end repeat
return soundList
end makeSoundsTable
Den 29. apr. 2011 kl. 22.20 skrev Ron Hunsinger:
> On Apr 29, 2011, at 10:34 AM, louie wrote:
>> Hi all I am trying to change the beep sound when running a script.
>> The below no workie.
>> Thanks for any help.
>>
>> tell current application
>> beep as "Tink"
>> end tell
>
> Try:
> do shell script "/usr/bin/afplay '/System/Library/Sounds/Tink.aiff'"
>
> You need the full, exact path to the sound file. If you know which beep you want at the time you write the script, hard code the full path in the script. If you won't know the "beep name" until runtime, you'll have to search for it in all the usual locations (~/Library/Sounds, /Library/Sounds, and /System/Library/Sounds), where it might appear with either a .aif or a .aiff filename extension. Something like:
>
> property dirs : {path to home folder, path to startup disk, path to system folder}
> property exts : {".aif", ".aiff"}
>
> on playBeep(beepname)
> set beeppath to missing value
> repeat with aDir in dirs
> repeat with anExt in exts
> set fullPath to (aDir as string) & "Library:Sounds:" & beepname & anExt
> tell application "Finder"
> if exists alias fullPath then
> set beeppath to fullPath
> exit repeat
> end if
> end tell
> end repeat
> end repeat
> if beeppath is not missing value then
> set beeppath to quoted form of POSIX path of beeppath
> do shell script "/usr/bin/afplay " & beeppath
> end if
> end playBeep
>
> playBeep("Tink")
> playBeep("Basso")
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>
Best regards
Tommy Bollman
--------------------------------------------------------------------------------------------------
Mollison's Bureaucracy Hypothesis:
If an idea can survive a bureaucratic review
and be implemented it wasn't worth doing.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >beep (From: louie <email@hidden>) |
| >Re: beep (From: Ron Hunsinger <email@hidden>) |