Today I was listening to music on my mac at work, and wondered if there was a way to adjust iTunes volume with a shortcut key. Turns out there isn't one unless iTunes is in focus, and iTunes is generally not in focus.
So what's the reason for this? No particular reason, but I did figure out a way, and I thought I'd share it.
I grabbed some code from Doug who has iTunes-related AppleScripts on his website. I then proceeded to plonk the code into a couple of Automater services. The two scripts are as follows:
Volume Down:
property volume_step : 10
tell application "iTunes"
if the sound volume is greater than volume_step then
set sound volume to (sound volume - volume_step)
else
set sound volume to 0
end if
end tell
Volume Up:
property volume_step : 10
tell application "iTunes"
if the sound volume is less than 100 - volume_step then
set sound volume to (sound volume + volume_step)
else
set sound volume to 100
end if
end tell
If you haven't used Automater before, it's quite a neat program. I followed some instructions on the web about how to go about using it to make AppleScripts into keyboard shortcuts. It's quite simple really.
- Open automater
- Create a new service
- Set 'Service receives' to 'no input' (at the top of the workflow)
- Search for the 'Run AppleScript' action in the left pane
- Drag the 'Run AppleScript' action into the workflow
- Paste your AppleScript into the resulting text area
- Save the service as some meaningful name
- Open system preferences > keyboard > shortcuts
- Select 'Services' from the left pane
- Scroll down to 'General' and find your newly created services
- Add keyboard shortcuts for them.
- Log-out and back in again.
On my MacBook I made my keybaord shortcuts to be ⌘F11 and ⌘F12 for volume down and up respectively. The reason for this is that matches the existing volume keys and basically becomes ⌘Fn+vol-down and ⌘Fn+vol-up.
So that's that, now you can control your iTunes volume independently from anywhere using system-wide shortcut keys. Not sure why you would want to do this but it is a pretty neat trick.