Search code examples
macosscriptingautomationapplescriptnotificationcenter

Toggle messages preview in notification center with applescript/quicksilver


Haven't ever scripted with apple script before was wondering if it was possible to create an applescript that could toggle the settings for messages in the notification that displays the message preview. I was then gonna use quicksilver to call that script, is this possible with applescript and would quicksilver be able to make the appropriate calls to initiate the script? I'm running mavericks OS.


Solution

  • This toggles the "Show message preview" checkbox:

    tell application "System Preferences"
        reveal pane id "com.apple.preference.notifications"
    end tell
    tell application "System Events" to tell window 1 of process "System Preferences"
        repeat with r in rows of table 1 of scroll area 1
            if name of UI element 1 of r is "Messages" then
                set selected of r to true
                exit repeat
            end if
        end repeat
        click checkbox "Show message preview" of group 1
    end tell