How do I make a applescript go to a tab in a system preference pane?

Discussion in 'Mac Programming' started by natatos, Sep 30, 2011.

  1. natatos macrumors regular

    Joined:
    Dec 23, 2008
    Location:
    Iowa
    #1
    I'm working on a applescript that when I run will change the scrolling direction in trackpad. Its for when I'm using my mouse I don't want to get used to going the other way than other computers I use. Heres the code
    Code:
    tell application "System Preferences"
        set current pane to pane "Trackpad"
            tell application "System Events"
                tell window "Trackpad" of process "System Preferences"
                    click checkbox "Scroll direction: natural"
                end tell
            end tell
        end tell
    	
    tell application "System Preferences"
        quit
    end tell
    Its at the line
    Code:
    tell window "Trackpad" of process "System Preferences"
        click checkbox "Scroll direction: natural"
    that I get messed up. I was able to make the selection in the mouse pane work but I would rather it be the trackpad one. How can I make it so the script goes to the tab scroll & zoom and what do I put for the checkbox name? Thanks for the help
     
  2. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #2
    You can't get to the trackpad pane unless you have a multitouch gesture capable trackpad active on your Mac. I (via google) found a recipe for doing it in terminal that requires you to log out and back in for it to take effect...

    Code:
    defaults write ~/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirection -bool false
    Of course anything you can do in terminal you can do in applescript using do shell script. Hopefully this gets you started in the right direction to find your answer.
     
  3. T1m macrumors newbie

    Joined:
    Dec 3, 2011
    #3
    This is my first ever forum post so hope it makes since and helps someone.

    Is this the answer / script you are looking for to reverse the Scroll Direction easily:

    Code:
    tell application "System Preferences"
    	activate
    	set current pane to pane "com.apple.preference.trackpad"
    end tell
    
    tell application "System Events"
    	tell application process "System Preferences"
    		tell tab group 1 of window "Trackpad"
    			click radio button "Scroll & Zoom"
    			click checkbox 1
    		end tell
    	end tell
    end tell
    
    tell application "System Preferences"
    	quit
    end tell
    Happy Scripting!!
     

Share This Page