Toggle Mail Classic View in Mountain Lion with I found a script on this site which I edited to make work with Mountain Lion, I thought. It works fine from Automator, but when I save as a service and assign a keystroke to it, it does not. Any help would be appreciated!

tell application "Mail" to activate

tell application "System Events"
    tell process "Mail"
        tell application "System Events" to keystroke "," using command down
        delay 0.1
        activate (first window whose name is "Viewing")
        click checkbox "Use classic layout" of group 1 of group 1 of window "Viewing"
    end tell
end tell
The script didn't focus the Viewing tab. Try this instead:

activate application "Mail"
tell application "System Events" to tell process "Mail"
    keystroke "," using command down
    tell window 1
        click button "Viewing" of tool bar 1
        click checkbox "Use classic layout" of group 1 of group 1
        click button 1
    end tell
end tell


If it still doesn't work, it might be because of a bug where the shortcuts for Automator services don't always work until you hover the services menu from the menu bar. See this question for other ways to assign shortcuts to scripts.