Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Good morning all, I would like to be able to turn the system sounds on my mac off (and back on) with an applescript activated as an extension for Alfred.

I have little knowledge of applescripts but I have found that I can open the system preference pane. How do I check and uncheck the "Play user interface sound effects" and "Play feedback when volume is changed" check boxes?

The start of my code is as follows

tell application "System Preferences" to activate (reveal anchor "effects" of pane id "com.apple.preference.sound")

Thanks guys

share|improve this question

1 Answer 1

up vote 2 down vote accepted

System Preferences and the Sounds prefpane don't have direct ways to script this. But you can use regular UI scripting in AppleScript:

tell application "System Preferences"
    reveal anchor "effects" of pane id "com.apple.preference.sound"
end tell

tell application "System Events"
    tell process "System Preferences"
        if value of theBox is not 1 then
            click checkbox 1 of tab group 1 of window 1
        end if
    end tell
end tell

Or if you want to set a certain value rather than just toggle the checkbox:

tell application "System Preferences"
    reveal anchor "effects" of pane id "com.apple.preference.sound"
end tell

tell application "System Events"
    tell process "System Preferences"
        set theBox to checkbox 1 of tab group 1 of window 1
        if value of theBox is not 1 then -- or "is 1"
            click theBox
        end if
    end tell
end tell

You can also explicitly say checkbox "Play user interface sound effects" of ... instead of just checkbox 1, but I'm not sure how this behaves with localizations.

share|improve this answer
    
Ahh ok, "click checkbox 1 of tab group 1 of window 1" is the bit I needed and didn't understand. Thank you –  Dave H Mar 21 '12 at 12:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.