r/applescript • • Dec 19 '22

Script to reverse the scroll direction.

Hi,

Didn't know where to post this. I've been having trouble creating an applescript to reverse the scroll direction on Ventura. I finally figured it out and am posting so others could use it.

The old script before Ventura was:

try
tell application "System Settings"
	reveal 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"
		tell application "System Settings" to quit
	end tell
end tell
end try

The working version for Ventura is this:

# This should work with Ventura 13.1 (2022-12-19)

do shell script "open x-apple.systempreferences:com.apple.Trackpad-Settings.extension" -- Opens the trackpad settings window
delay 0.7 -- The delay is there to make sure the System Events can click buttons.
tell application "System Events"
    tell process "System Settings"
	    click radio button 2 of tab group 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
	    click checkbox "Natural scrolling" of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
	    tell application "System Settings" to quit
    end tell
end tell

If anybody finds a better way, please let me know!

10 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/rojasgabriel Sep 27 '23

I have no Apple Scripts experience so I was struggling to find a way to make this work. Thank you so much! I shift a lot between mouse and trackpad and have opposite preferences for scrolling directions so I really needed this to have a smoother workflow