AppleScript Mouse/Keyboard Settings?

Is it possible to script the mouse and keyboard panel in System Preferences? I want to be able to build a toggle between two states:

–Left-handed mouse (with button switched–right button is single click, left button is “right click”)
–Right-handed mouse (normal left/right button setup)

Thanks!

For Magic Mouse I was only able to get, not set the value:

tell application "System Preferences"
	reveal pane "Mouse"
	tell application "System Events"
		tell process "System Preferences"
			tell window "Mouse"
				tell group 1
					tell pop up button 1
						return properties
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

return value works better

I figured a way around the problem.

As a sort of off-topic explanation:

I have learned to left-mouse out of ergonomic necessity at work, despite being right-handed (I right-hand at home where I have a better setup). And I do a “true” left mouse–I swap the mouse buttons so single-click is the right button (under my index finger) and “right click” is on the left button.

But I do feel kinda sorry for other people trying to use my workstation the normal way, so I wanted to make a toggle for it.

I’ve been messing with an XKeys Button Panel and Xkeys Desktop using ControllerMate. When I made this query, I was looking to use ControllerMate to run an AppleScript to do the toggle.

As luck would have it, ControllerMate itself has a way to modify the button behavior of my mouse (Logitech) in a more direct fashion. It’s a little complicated to set-up the logic the first time, but thankfully there is a tutorial for a very similar idea on the site. Pretty cool.