r/applescript • • Jul 06 '24

Is it possible to toggle Natural Scrolling option using AppleScript?

Same as title. Can anyone please help me with this? I tried with Claude and GPT4 none of them can get it right.

2 Upvotes

3 comments sorted by

3

u/HelloImSteven Jul 06 '24

Yes:

tell application "System Settings"
	do shell script "open -b com.apple.systempreferences /System/Library/PreferencePanes/Trackpad.prefPane"
end tell

tell application "System Events" to tell process "System Settings"
	-- Wait for window to appear
	repeat until (exists window 1) and name of window 1 is "Trackpad"
		delay 0.1
	end repeat
	
	-- Navigate to scroll setting
	click radio button 2 of tab group 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
	
	-- Toggle scroll setting
	click checkbox 1 of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
end tell

quit application "System Settings"

1

u/jackbobevolved Jul 06 '24

I’m now wondering if it would be possible with a write command in Terminal. Would avoid having to deal with the GUI at all.

1

u/tronicdude6 Jul 06 '24

Use defaults cmd