Skip to content

Instantly share code, notes, and snippets.

@TaufikAchmad
Last active January 5, 2025 23:33
Show Gist options
  • Save TaufikAchmad/03a290f0e019a403e8fd9808b7a43d3b to your computer and use it in GitHub Desktop.
Save TaufikAchmad/03a290f0e019a403e8fd9808b7a43d3b to your computer and use it in GitHub Desktop.
AppleScript to toggle scroll behavior in macOS Sonoma
-- Check the current state of Natural Scrolling
tell application "System Settings"
activate
end tell
tell application "System Events"
tell process "System Settings"
delay 0.5
click menu item "Trackpad" of menu "View" of menu bar 1
delay 0.5
click the radio button 2 of tab group 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Trackpad"
click checkbox 0 of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Trackpad"
set isNaturalScrollingOn to value of checkbox 0 of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Trackpad" as boolean
end tell
end tell
tell application "System Settings" to quit
-- Set the shortcut name based on the current state
if isNaturalScrollingOn then
set shortcutName to "Natural Scrolling (On)"
else
set shortcutName to "Natural Scrolling (Off)"
end if
-- Display a dialog with the updated shortcut name
display dialog shortcutName buttons {"OK"} default button "OK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment