Hi all, I am a college student and I am taking a compositing class. The school has really nice Mac Pro’s, but for whatever reason they have the preferences for the mice (Apple Mighty Mouse) set to one button instead of two. I wrote a script for my class that changes this in the system preferences, sets the desktop background to a neutral gray, and also copies a folder from the network to the local HD. These are all things that I and the rest of the students in my class have to do on a day to day basis so the script would be really helpful. The problem is IT has disabled “Enable access for assistive devices” so my script which should work perfectly doesn’t anymore. Is there a way to change the mighty mouse settings without using System Events to change the System Preferences?
Thanks!!
(*VSFX270 Startup Script v1
By Robert Gilkes
This script changes Mighty Mouse right mouse button
from default one button to two button mouse, sets the
desktop background to a neutral gray color (sampled from
Shake interface, and copies nreal folder from user's
network Home space to local.*)
--Set right mouse button to "Secondary Button" from default "Primary Button"
tell application "System Preferences" to activate
tell application "System Events"
tell process "System Preferences"
click button 12 of scroll area 1 of window "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
tell application "System Preferences" to quit
--Download "Shake" gray JPG and apply as desktop background
set bgColor to "Macintosh HD:Work Folder:gray.jpg"
tell application "URL Access Scripting"
download "http://studentpages.scad.edu/~rgilke20/gray.jpg" to bgColor replacing yes
end tell
tell application "Finder"
set desktop picture to bgColor
delete bgColor
--Checks for nreal folder on network and copies to local
set networkNreal to "Macintosh HD:Users:mac_user:Desktop:ATL-HOME:nreal"
set localNreal to "Macintosh HD:Users:mac_user"
if exists networkNreal then
duplicate networkNreal to localNreal replacing yes
end if
end tell
Model: Mac Pro 3Ghz Quad Core Xeon 4GB DDR2
AppleScript: 1.10.7
Browser: Firefox 2.0.0.9
Operating System: Mac OS X (10.4)
Now, don’t get all excited, I don’t have a full answer for you, I’m just saying that this is a really great idea. I have the same problem and, having a mighty mouse at home, it gets really annoying when the right click won’t click. My first suggestion would be to use GUI Scripting, but reading your post again I see you already know about that, and that is your problem. The only thing I can think of is to go into your Library and look for one of those com.apple files, and see if one of them controls either the “Enable access for assistive devices” pref or the mouse button pref itself. Cool idea!
the value of the buttons is stored in ~/Library/Preferences/com.apple.driver.AppleHIDMouse,
but just changing the value doesn’t take effect.
It probably works, if you log out/in after running this script
tell application "System Events"
if {"System Preferences"} is in (get name of processes) then quit application "System Preferences"
end tell
do shell script "/usr/bin/defaults write com.apple.driver.AppleHIDMouse Button2 -int 2"
That would work, but the computers are setup so that when you log out it resets any preference changes you made back to their defaults. Does anyone know of a way to I guess “refresh” the OS to recognize the change in the preferences files?
Does anyone know what gets refreshed on the system when the mouse settings are changed from the system preferences that doesn’t when they are changed from the com.apple file?
Since this seems like an impossible task I have a somewhat different question. Can the “Enable access for assistive devices” option be turned on from a script without the need for an administrator password?
This probably won’t work for you, as it does require an administrator password, but you can access the “Enable access for assistive devices” (which I keep typing as “Enable assistance for assistive devices”) through AppleScript Utility, under the heading “Enable GUI Scripting”. Again, it does require a password.
yea, thanks, but that wont work because the IT department has the admin password. does anyone know what gets updated or restarted when a preference is changed in the system preferences? im trying to figure out a way to make the system recognize the change to the preference plist file
I know there are some UNIX people out there, and I know there is something like "defaults write com.apple.universalaccess " etc. If only they would tell me how, hint hint. Please?