tags:

views:

37

answers:

1

I want to click a radio-button in System Preferences if another radio-button is selected, like this:

tell application "System Preferences"
    activate
end tell

tell application "System Events"
    tell process "System Preferences"
        click menu item "Mouse" of menu "View" of menu bar 1

if radio button "Right" is selected <-- pseudo-code
    tell window "Mouse"
        tell radio group 1
            click radio button "Left"
        end tell
    end tell
end if

if radio button "Left" is selected <-- pseudo-code
    tell window "Mouse"
        tell radio group 1
            click radio button "Right"
        end tell
    end tell
end if

end tell
end tell

anyone know how to do this?

A: 

The following script will revert the primary button to "Left" if it is currently set to "Right":

tell application "System Preferences"
    activate
    set current pane to pane id "com.apple.preference.mouse"
end tell

tell application "System Events"
    tell process "System Preferences"
        tell radio group "Primary mouse button:" of window "Mouse"
            if value of radio button "Right" is 1 then
                click radio button "Left"
            end if
        end tell
    end tell
end tell

Setting the primary button to "Right" will confuse the hell out of most users.

sakra
Thanks for you help!Just needed to plug in an else-statement to get it to work.You're right most users will fret if their primary button is set to "Right" - however due to a shoulder-injury I constantly change hands when using my trackball.
timkl