12

As everyone will know (who has Mac OS X Lion), by default, scrolling is inverted to make it a bit like the iPhone.

Problem: There is no way to have "normal scrolling" for a USB mouse, and "natural/inverted" scrolling for the trackpad. The setting (even though it is listed in both the mouse and trackpad settings) applies to both.

Question: Could someone, who is experienced with Automator or AppleScipting, please give me a few tips on how to make a shortcut that can toggle the inverted setting? I need this as when I'm at home, I have my Mac Book Air plugged to my Keyboard, Mouse and Monitor, and I'd like a quick way to change this setting

studiohack
  • 13,468
  • 19
  • 88
  • 118
jtnire
  • 277
  • 1
  • 5
  • Just curious, is opening Preferences not fast enough? –  Aug 09 '11 at 17:59
  • 1
    I'm constantly docking and undocking my mac book, so a nice shortcut to change this would be nice. –  Aug 09 '11 at 18:01
  • 4
    Why are people voting down this post? Is there something I have done wrong? –  Aug 09 '11 at 18:06

1 Answers1

3

This ought to do it:

tell application "System Preferences" to set the current pane to "com.apple.preference.mouse"
tell application "System Events"
    tell process "System Preferences"
        click radio button "Point & Click" of tab group 1 of window "Mouse"
        click the first checkbox
    end tell
end tell

Final Working Solution:

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.trackpad"
end tell

tell application "System Events"
    tell process "System Preferences"
        click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad"
        click checkbox 1 of tab group 1 of window "Trackpad"
    end tell
end tell

tell application "System Preferences"
    quit
end tell
jtnire
  • 277
  • 1
  • 5
fireshadow52
  • 81
  • 10
  • This is what I have so far: http://pastebin.com/L0Tf7NSh It says it can't find checkbox 1 –  Aug 09 '11 at 18:27
  • `...checkbox of group 1` try that. –  Aug 09 '11 at 18:32
  • "System Events got an error: Can’t get group 1 of process "System Preferences". Invalid index." –  Aug 09 '11 at 18:34
  • Ok, this works: http://pastebin.com/JGUvA8U9 Any ideas on how I get the window to close? – jtnire Aug 09 '11 at 18:42
  • Ok: this is my final solution: http://pastebin.com/67PH15Ee – jtnire Aug 09 '11 at 18:49
  • In case anyone else would try this out, the value isn't updated immediately when modifying `.GlobalPreferences` directly. `k=com.apple.swipescrolldirection; r=\`defaults read -g $k\`; [[ $r == "1" ]] && b=false || b=true; echo $b; defaults write -g $k -bool $b` – Lri Aug 10 '11 at 13:06
  • This is not working for me for Mac OS 10.9.5 – Asad Iqbal Dec 26 '14 at 22:42