Muting and unMuting iTunes

Hi,

I am trying to write an applescript that will serve as an alarm clock, but I am not sure how to mute/unmute the system. I need something that will check to see if the system is muted, and if it is, to unmute. I tried this, which did not work:

if (get mute) = false then
set mute to not (get mute)
end if

presumably, ‘get mute’ returns a false flag if the system is muted, so negating it should make it true - but apparently not.

Not quite, vgoklani. If the sound is muted, then iTunes’ mute property will be true.

So your script works like this: If the mute property is false (and the sound can therefore be heard), then your script will set mute to true (to silence the sound). If mute is true (and no sound can be heard), then the script does nothing.

To toggle the mute property, try something as simple as:

tell application "iTunes"
	
	set mute to not mute
	
end tell

Oh, it appears that I have made a mistake - the mute in iTunes is not tied into the system mute! Is there a way for me to control the system mute function (the one where you can mute the sound by pressing a button on the keyboard).

-V-

Sure. This also toggles mute - but this time for the system sound:

if output muted of (get volume settings) then
	set volume without output muted
else
	set volume with output muted
end if

Note that the method kai mentioned was introduced in one of the OS X 10.3.x updates.

Yes - the method requires at least Standard Additions 1.9.4, which was actually included with Mac OS 10.3.5 - and which requires Mac OS 10.3 or later. (Before that, I used Jon’s Commands to achieve something similar.) :slight_smile: