I'm trying to create a script that will automatically change the mouse tracking speed for me, as I switch between mice (Mighty Mouse and Logitech Notebook wireless mouse) every day, and it's annoying to change the tracking speed manually every time I switch mice. Anyway, I've been wanting to learn how to use GUI scripting in AppleScript and figured this would be a good chance to do that. I've run into a problem. I've got the following code so far:
System Preferences opens fine, but then I get the following error:
and the line "click button "Keyboard & Mouse"" is highlighted. Can anybody tell what I'm doing wrong? I've got "access for assistive devices" checked in System Preferences->Universal Access.
Code:
tell application "Finder"
open application file "System Preferences" of folder "Applications" of startup disk
end tell
tell application "System Events"
tell process "System Preferences"
tell window "System Preferences"
tell scroll area 1
click button "Keyboard & Mouse"
end tell
end tell
end tell
end tell
System Preferences opens fine, but then I get the following error:
Code:
System Events got an error: NSReceiverEvaluationScriptError: 4