开发者

applescript and magic mouse

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 star开发者_如何学编程t. 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜