views:

98

answers:

1

I want to applescript the scrolling behaviour of my magic mouse so I can toggle it on and off with a key press. Trouble is, I'm a designer not a developer, so don't have a clue where to even start. I've experimented with Script Editor and Automator and got nowhere. Can someone help or best of all, just write the script for me? I can't believe it's that hard to switch off and on a check box in a Snow Leopard Preference Pane?

Cheers,

Dan

A: 

UPDATE: I did some digging around, and there is a command for turning off horizontal scrolling:

defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseHorizontalScroll -bool NO

I'm sure there is one for vertical scrolling (though I'm not sure why anyone would do that, designer or otherwise). There is also an application called MagicPrefs that will help unlock and set a bunch of hidden features of the mouse. That might actually be what you need to sort out your mousketeering issues.


The reason why this is so difficult is because Apple doesn't like it when people futz with system preferences like this, but they do have a shell command called defaults that lets users toggle all sorts of stuff. I'm not at my Snow Leopard machine at the moment, but if you want to do this now, then you'll need to put on your programming cap for a minute.

As an example, if you wanted to enable momentum scrolling, then you would write an Applescript like this:

do shell script "defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseMomentumScroll -bool yes"

To turn it off, then you need only change the last word to no and re-run. There are a number of tutorials out there and lists of settings to toggle if just know where (and how) to look. Search for "Mac OS X defaults" in your search engine of choice and you're bound to find what you need.

If you want to write something from scratch, then near as I can tell from a quick search, /System/Library/Extensions/AppleMultitouchDriver.kext is the file that holds all the settings that you can change. Open the file in BBEdit and look at the info.plist file, which contains XML (albeit a bit wonky). The trick is to find the setting in the info.plist file that toggles the scrolling, if one exists.

Just be sure to think twice about what you are toggling before you hit the "Run" button. Apple left out certain settings from the System Preferences for a reason. I used to be a designer yet I found this to be a very rewarding experience so I suggest giving it a go.

Philip Regan
that's really helpful stuff, Philip, thank you. I did try out Magic Prefs previously and it does a whole heap of useful stuff, but not disabling horizontal scroll to my knowledge. I'm still a bit sceptical about my ability to actually make an applescript work, especially where it comes to want I really want it to do, which is be assigned to a function key so that I can just hit it when I'm in indesign (and turn HS off) and then hit it again when I'm in Safari (and turn HS on). I'm prepared to pay someone to do this for me...
Dan
you know what. I just checked out magficprefs again, and it does allow the switching off of horizontal scrolling. So we're definitely halfway there! I think you can make presets with it too.
Dan
I've Googled for several related terms (the last being `"Magic Mouse" AND "disable vertical" scrolling`), and I can't find anything that disables vertical scrolling. (Maybe because Apple considers that a core feature of a mouse now? But that's just speculation on my part.) I don't have a Magic Mouse myself, so I can't peak into the driver file myself to know if a flag actually exists. You could just try `do shell script "defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseVerticalScroll -bool NO"` and see what happens next if you feel brave enough.
Philip Regan

related questions