I’m writing a script that needs to be able to gradually reduce the system volume from wherever it is when the script start.
I know I can set the system volume with “set volume 5” (or any other number between 0 and 8) but I can’t seem to work out how to get what the system volume is currently.
“get volume” doesn’t work.
In the standard additions dictionary you can find the ‘get volume settings’ and ‘set volume settings’ commands. Output volume is an integer between 0 and 100. Here’s a simple script for getting volume…
set volumeSettings to (get volume settings)
if (output muted of volumeSettings) then
display dialog "Volume: Muted"
else
set theVolume to (output volume of volumeSettings)
display dialog (("Volume: " & theVolume) as string)
end if
thanks for the reply, took me a while to get round to using it.
I can see how to get the system output volume into say, x “set x to item 1 of ((get volume settings) as list)”
But how would i use the set volume settings so “output volume:x” ?
Do not use ‘item 1 of (get volume settings)’. That might work today, but it might not work tomorrow if Apple change the list of properties ‘get volume settings’ returns. They might change the order, they might add additional options (e.g. 'subwoofer output volume, line out volume, internal volume, etc.)
Instead, be very specific as to what you want:
set x to output volume of (get volume settings)
Referencing it by name avoids the list order issues.
How would I attach a sound to an applescript? Currentlly mine “beeps”, but I’d like to assign a specific sound when it runs. Any ideas? Is this hard to do?
at last im reading all your message, and try, and resume all in 1 line to up and 1 line to down the volume
im make this code for applescript for up and down the system volume
set volume output volume its the instruction for set the system volume
(get volume settings) read the group of value for system volume settings
(output volume of its the actual value of system volume
the minus or plus indicate to decrease or increase the value to system volume
the 7 its the value for the steps to modify the volume from 0 to 100, you can put 1,2,3,4,5,6,7,8,9,10, etc
for up system volume write this
set volume output volume ((output volume of (get volume settings)) + 7)
for down system volume write this
set volume output volume ((output volume of (get volume settings)) - 7)
enjoice
carlos cabrera