Enabling/Disabling Mouse-scrolling with AppleScript

by harryvermeulen

Mouse Scrolling preference pane.

The accidental scrolling of my Magic mouse in Photoshop, Illustrator and other applications was pissing me off, so I wrote a bit of AppleScript to switch mouse-scrolling on and off in the System Preferences. It’s not the most elegant or efficient piece of code, so feel free to comment, add or improve.

tell application "System Preferences"
	activate
	reveal anchor "Mouse" of pane id ("com.apple.preference.universalaccess")
end tell

tell application "System Events"
	tell process "System Preferences"
		tell window "Universal Access"
			click button 1 of tab group 1
			click checkbox "Scrolling" of sheet 1
			set checkboxstate to value of checkbox "Scrolling" of sheet 1
			click button "Done" of sheet 1
		end tell
	end tell
end tell

tell application "System Preferences"
	quit
end tell

if checkboxstate is 1 then
	display dialog "Scrolling is enabled." giving up after (1) buttons {"Ok"}
else
	display dialog "Scrolling is disabled." giving up after (1) buttons {"Ok"}
end if

To launch the script with a keyboard shortcut, I installed FastScripts (http://www.red-sweater.com/fastscripts/) which is free for the first 10 custom keyboard shortcuts. Assign the script to a shortcut and you can toggle your scrolling on and off in a few seconds!

Enjoy.

Advertisement