Staff Member

The following will approximate it (minus the visual and audio cues that it's changed):

Code:

set currentVolume to output volume of (get volume settings) -- in the range 0 to 100 (integer)
set newVolume to round (currentVolume * 64 / 100) -- convert to the range 0 to 64 (float)
if newVolume < 64 then set newVolume to newVolume + 1 -- increment the volume
set volume output volume (newVolume * 100 / 64) -- convert back to the range 0 to 100

The technical details are below, but they're not important if you're not too concerned about details.

Unfortunately it's more complicated than it should be. The actual system volume is an integer from 0 to 100, but the normal range with the up/down volume keys is 0 to 16, and when using option-shift-volume up/down the range is effectively 0 to 64 (as there are four increments for each square). As the actual volume is stored as an integer, numbers don't convert cleanly between ranges, so for example 0.25 squares is volume 1, 0.5 squares is volume 3, 0.75 squares is volume 4, etc. Apple's mapping between the two ranges doesn't seem to follow an obvious formula (a quarter of a square increase can correspond to an actual volume increase of 1, 2, or 3), so the above won't match it perfectly, but will be fairly close.

Thanks for that nice script and explanation, however I was hoping to get the graphical and audial feedback. I know you can do keystrokes with AppleScript however I'm unable to tell applescript to combine Shift+options+F12 successfully. Any help with that?

Unfortunately, this won't do what you want; 111 corresponds to F12, but the media keys (volume up, volume down, etc) are treated as different keys. In theory there's a separate key code for the "volume up" key (72), but it doesn't work either. I can't seem to find any workaround, sorry.

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.