I want to set the screen sharing password using apple script and check the option 'VNC viewers may control screen with password'. I'm new at apple script, and what I have accomplished is only checking the 'Screen Sharing' option under the Sharing pane of System Preferences.
Here's what I have so far:
tell application "System Preferences"
set current pane to pane "com.apple.preferences.sharing"
end tell
tell application "System Events"
tell process "System Preferences"
tell checkbox 1 of row 1 of table 1 of scroll area 1 of group 1 of window "Sharing" to if value is 0 then click
end tell
tell process "System Preferences"
click button 1 of group 1 of window "Sharing"
delay 1
set value of text field 1 to "p"
end tell
end tell
But the code above will prompt me an error:
Can’t get text field 1 of process "System Preferences". Invalid index