1

I want to toggle natural scrolling without using third-party software, as is done here and here. However, these scripts no longer work in macOS Sonoma 14.0 because the layout of the System Settings application has changed.

This is not a duplicate of similar older questions. Those questions have solutions that work on older versions of macOS, but that do not work on Sonoma. Please do not mark this question as a duplicate.

2 Answers2

2

After a lot of trial and error, I finally managed to make a script that works in Sonoma. Try this:

-- Open trackpad settings
open location "x-apple.systempreferences:com.apple.Trackpad-Settings.extension"

tell application "System Events" tell application process "System Settings" tell group 1 of group 2 of splitter group 1 of group 1 of window 1

        -- Select "Scroll & Zoom" tab
        repeat until tab group 1 exists
            delay 0
        end repeat
        tell tab group 1
            click radio button 2
        end tell

        -- Toggle "Natural scrolling" flag
        repeat until group 1 of scroll area 1 exists
            delay 0
        end repeat
        tell group 1 of scroll area 1
            click checkbox 1
        end tell

        delay 0.1
        tell application "System Settings"
            quit
        end tell

    end tell
end tell

end tell

0

That's the problem with GUI scripting that automates human actions moving the pointer, rather than scripting the actual command required. If the UI changes, the script breaks.

Have you tried using:

defaults write -g com.apple.swipescrolldirection -bool NO

in the Terminal? You'll need to log out and back in to see the result.

benwiggy
  • 35,635
  • Unfortunately logging out and logging back in every time I plug in a mouse defeats the purpose of automating this: saving time. – user5104897 Nov 15 '23 at 20:25