Last active
January 5, 2025 23:33
-
-
Save TaufikAchmad/03a290f0e019a403e8fd9808b7a43d3b to your computer and use it in GitHub Desktop.
AppleScript to toggle scroll behavior in macOS Sonoma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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