Here is my version that I use for the Mighty Mouse Button Right to be used as a Back Button. It’s kinda’ dorky with the AppleScript icon bouncing in the dock, and it’s slow. But, it’s free, it works, and it’s better than $20 for Steermouse. Also, I use all of my AppleScripts with TextExpander for the triggering so it’s easy to switch back and forth. Now on to the scripts.
This is the main AppleScript application that I named Command Left Brace. It can be manually assigned to a button in Mouse Preferences or it can be automatically assigned via another activating AppleScript via the menu bar or any other trigger application such as Butler, TextExpander, etc.
tell application "WebKit"
activate
end tell
tell application "System Events"
key code 33 using {command down}
end tell
You can substitute Webkit with Finder, Safari, Firefox, or any other app.
Then “Save As” the AppleScript as an application with the following options:
File Format: Application
Uncheck the following: Run Only, Startup Screen, Stay Open
Here is a pic:
http://i30.tinypic.com/2rgfi4k.jpg
Now just go to Mouse Preferences and assign this AppleScript application to any Mighty Mouse Button.
Below are some more advanced and time-saving AppleScripts that I use. They can be used with TextExpander, the menu bar, AppleScript application, or any other AppleScript triggering method to automatically assign actions to the Right Button.
I use TextExpander to trigger the Mighty Mouse Right Button to Primary Button (click), Secondary Button (right click), or Other (Command Left Brace above). You can modify the scripts below for any button on the Mighty Mouse, but you’ll want to use trial and error along with UI Elements, or PreFab UI Browser.
Here are my AppleScripts to turn the Right Button to these three options:
Primary Button:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
tell application "System Events"
tell process "System Preferences"
click radio button 2 of tab group 1 of window "Keyboard & Mouse"
click pop up button 3 of tab group 1 of window "Keyboard & Mouse"
click menu item 1 of menu 1 of pop up button 3 of tab group 1 of window "Keyboard & Mouse"
end tell
end tell
end tell
delay 0.1
tell application "System Preferences" to quit
Secondary Button:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
tell application "System Events"
tell process "System Preferences"
click radio button 2 of tab group 1 of window "Keyboard & Mouse"
click pop up button 3 of tab group 1 of window "Keyboard & Mouse"
click menu item 2 of menu 1 of pop up button 3 of tab group 1 of window "Keyboard & Mouse"
end tell
end tell
end tell
delay 0.1
tell application "System Preferences" to quit
For the Back Button I use this script so that Mouse Preferences will choose the “Command Left Brace” as the AppleScript to open when the Right Button is clicked. When the “Other” menu option is clicked for the Right Button, a Finder type dialog box opens to allow the user to select an application for the Right Button to open. For me this location to choose from is HD:Library:Scripts, so that’s where I put a copy of the “Command Left Brace” AppleScript Application. So the AppleScript below just manuevers via the UI to select this file from the dialog box.
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
tell application "System Events"
tell process "System Preferences"
click radio button 2 of tab group 1 of window "Keyboard & Mouse"
click pop up button 3 of tab group 1 of window "Keyboard & Mouse"
click menu item 12 of menu 1 of pop up button 3 of tab group 1 of window "Keyboard & Mouse"
end tell
end tell
end tell
tell application "System Events"
key code 125
delay 0.2
keystroke "command left"
delay 0.5
key code 36
end tell
delay 0.5
tell application "System Preferences" to quit
Sorry if any of this was confusing. I just wanted to share with others since I just finished them and made them all work. I couldn’t quickly find any scripts so I just made my own. Sorry again, if my post is unclear, I wasn’t in the mood to write a step-by-step with pics. I just wanted to get this stuff out there for everyone.
Cheers.