1

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

2

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.

  • 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .