I want to be able to press an Fkey and have a script raise the volume on the Mac to a certain level, play a very brief sound file, then lower the volume back to zero (I normally keep the sound turned down). Is this possible? The Mac is a G5 DP 867MHz, I think it’s called the mirrored door one? Tiger 10.4.8. Thanks in advance for your time!
Have you got a script in mind or you asking if someone will write it for you?
AppleScript itself doesn’t have the means to run a script from an Fkey but there are lots of applications “out there” that will. [QuicKeys comes to mind. I use FastScripts. There are others]
Hi
I use fastscripts like adam has mentioned and it works perfect, i beleive theres a lite version which is free
and limits you so you can set up ten keyboard shortcuts where as the normal version is unlimited.
Do you have a particular application in mind that will play the sound file? (More info needed!)
If a script can’t be triggered by a hotkey without an external program, fine, if I can get an icon or button I can click, that will be fine.
As to what app plays the sound, preferably not iTunes, perhaps Quicktime or perhaps there is a small freeware program you know of . . .
I don’t have a script in mind, the extent of my scripting ability has been basically making minor modifications on existing scripts. I would be willing to pay a small fee if anyone is interested, please let me know.
set thesound to choose file -- returns an alias to the sound file
set volume output volume 100
tell application "QuickTime Player"
activate
open thesound
play movie 1
tell movie 1
repeat while playing is true
end repeat
end tell
end tell
set volume output volume 0
if its the same sound everytime you can set thesound variable to that instead of choosing it everytime
save this down as an application, you could also add a bit to quit quicktime after its finished!!
I think they may be a facility in “jons commands” (a scripting addition) that plays sounds without opening an app like quicktime
you’ll have to look into it!!
I’d recommend a faceless background application for this kind of job, Dave. Something like Play Sound should fit the bill, and won’t clutter up your screen unnecessarily.
While the application’s play command features (among other things) an at volume parameter, it may not work quite as intended. So you might have to adjust the system volume (as pidge has demonstrated).
This variation checks the current volume setting, turns up the volume, plays the sound ” and then restores the original volume setting. A delay is necessary to ensure that the volume isn’t turned down while the sound is still playing.
set sound_file to (path to "ssnd" as Unicode text) & "Hero.aiff" as alias
set original_volume to output volume of (get volume settings)
set volume output volume 100
tell application "Play Sound" to play sound_file
delay 1.5 (* adjust as necessary *)
set volume output volume original_volume
This script uses the built in Alert sound to play your file.
It toggles the Alert sound from the current one to your file and back.
So no need for third party apps.
Just change the property mySound to the full path to your sound file.
property mySound : "/Users/UserName/Documents/Tiger7.mp3" -- name of a sound file and path to it
global currentSound, myMACaddress
--figure out where the beep sound is located inside the Application Bundle (package)
on run
-- get current system alert sound
set myMACaddress to words 2 thru 7 of (do shell script "ifconfig en0 ether | grep -i ether" as string) as string
set currentSound to do shell script "defaults read ~/Library/Preferences/ByHost/.GlobalPreferences." & myMACaddress & " com.apple.sound.beep.sound"
set av to alert volume of (get volume settings)
set volume alert volume 100
set_system_sound() -- set new sound
beep
set volume alert volume av
do shell script "defaults write ~/Library/Preferences/ByHost/.GlobalPreferences." & myMACaddress & " com.apple.sound.beep.sound " & currentSound
end run
on set_system_sound()
do shell script "defaults write ~/Library/Preferences/ByHost/.GlobalPreferences." & myMACaddress & " com.apple.sound.beep.sound " & mySound
end set_system_sound
But this doesnlt solve the issue that volume might be temporarily low or muted.
I tried the following but it does not work:
set {VolSetts, output muted of (get volume settings), alert volume of (get volume settings)} to {get volume settings, false, 80}
tell application "Extra Suites" to ES play AIFF alias "HD:System:Library:Sounds:Bottle.aiff"
set volume settings to VolSetts -- compile error: expected EOL but found "to"
Ok I Made the small change to reset the Alert sound to its original volume ( see script above)
Note : The ‘alert volume’ and ‘volume output’ levels are different.
The ‘volume output’ is the overall system Sound output.
The ‘alert volume’ is the output for system alerts only.
If the ‘alert volume’ is set at 100 (its max), But the ‘volume output’ is mute, you get no sound
Its is a hidden file held in the byhost folder in the preferences folder.
Are you saying the script did not work? Are you getting an error.
what system are you on.
I know some prefs do not get created until you make a change.
This could be one of them. To make a change go to System Prefs and change the Alert sound to a new one close System prefs.
run the script.
The only part of the script that needs changing is the property property mySound :
I understand the other script works for you but it is always of interest of why a script works else where but not every where.
Hi Adam,
Maybe its something to do with the intels?
what do you get if you do:
set myMACaddress to words 2 thru 7 of (do shell script "ifconfig en0 ether | grep -i ether" as string) as string
set currentSound to do shell script "defaults read ~/Library/Preferences/ByHost/.GlobalPreferences." & myMACaddress & " com.apple.sound.beep.sound"
I just noticed that after I did a clean install this time, I no longer have the old beep sound when using the beep command. After I sent the computer in to fix at Apple, it wouldn’t load classic. Maybe they put in the wrong firmware or something. Anyway, I didn’t install OS9 and classic this time. Could it be that the com.apple.sound.beep.sound is the default preference left over from classic?
/System/Library/LoginPlugins/BezelServices.loginPlugin/Contents/Resources/volume.aiff
is the volume feedback sound.
Here’s as close as I could get to playing the alert without a window, using Quicktime.
set wasopen to true
try
tell application "System Events" to process "QuickTime Player"
on error
set wasopen to false
ignoring application responses
tell application "QuickTime Player" to activate
tell application "QuickTime Player" to close window 1
tell application "System Events" to set visible of (process "QuickTime Player") to false
end ignoring
end try
tell application "QuickTime Player"
open ("Macintosh HD:System:Library:LoginPlugins:BezelServices.loginPlugin:Contents:Resources:volume.aiff")
set visible of window 1 to false
if not wasopen then tell application "System Events" to set visible of (process "QuickTime Player") to false
play document -1
delay 0.5
close document -1
end tell
if wasopen = false then tell application "QuickTime Player" to quit