Changing scrollbar visibility with Applescript (in Lion)

397 views Asked by At

I am trying to write an applescript that would change the visibility of Lions scrollbar (System Preferences > General). Normally I like to keep setting at "Automatically based on input device", but at home I use Wacom tablet, so I need to switch to Always

This is what I have so far:

    tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.general"
end tell
tell application "System Events"
    if UI elements enabled then
        try
            tell process "System Preferences"
                click radio button "Always"
            end tell 
    end try
    end if
end tell

But I always end up with an error

--> error number -1728 from «class radB» "Always" of «class prcs» "System Preferences"

at line "click radio..."

I tried various variation

click radio button 3 of Window 1

click radio button 3 of radio group 1 of window 1     -- error number -1719

I am obviously doing something wrong, but can't figure out what.

1

There are 1 answers

1
AudioBubble On BEST ANSWER

If you have the Developer Tools installed, there is an Accessibility Inspector application that will show you the hierarchy of a particular UI element:

click radio button "Always" of radio group 2 of window 1