문제

I'm trying to make an AppleScript to change an option in System Preferences. The checkbox is revealed by clicking "Mouse Options..." in the "Mouse and Trackpad" menu of the "Accessibility" pane. The script I have written so far is able to navigate through System Preferences so that the desired checkbox is visible to be clicked. However, I can't find a way to click the checkbox, seemingly because the checkbox is within a sort of 'drop down tab' on the window. None of the tutorials I have found online deal with this specific issue.

My code so far-

tell application "System Preferences"
 activate
 set the current pane to pane id "com.apple.preference.universalaccess"
 get the name of every anchor of pane id "com.apple.preference.universalaccess"
 reveal anchor "Mouse" of pane id "com.apple.preference.universalaccess"
 tell application "System Events" to tell process "System Preferences"
    click button 5 of window "Accessibility"
 end tell
end tell

The desired checkbox is "Scrolling". I expected that the following code would work, but it does not- it clicks checkboxes in the background, not the one in the tab.

tell application "System Events" to tell process "System Preferences"
    click checkbox 1 of window "Accessibility"
 end tell

This is my first time using AppleScript, I should mention. Any help would be much appreciated.

도움이 되었습니까?

해결책

The 'drop down tab' is called a sheet:

tell application "System Preferences"
 activate
 set the current pane to pane id "com.apple.preference.universalaccess"
 reveal anchor "Mouse" of pane id "com.apple.preference.universalaccess"
  tell application "System Events" to tell process "System Preferences"
   click button 5 of window 1
   click checkbox 1 of sheet 1 of window 1
  end tell
end tell
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top