Here on Tahoe, modifying a setting for “Auto delete verification codes” in the “Autofill & Passwords” pane ( opened here by “do shell script “/usr/bin/open ‘x-apple.systempreferences:com.apple.Passwords-Settings.extension’”” ) modified the “com.apple.onetimepasscodes.plist” file. That file only holds that one preference. I think you might have a bit more complexity here than you thought.
My overall goal is to write a script that detects the status of the plist and based upon whether the value of the checkbox is 0 or 1, then open the preference’s pane, and with the use of UI click the checkbox button slider to the opposite position. The following script detects the value of the checkbox in that pane. If it is 0, the script clicks the checkbox to slide its UI slider to the opposite end.
on AutoFill()
do shell script "/usr/bin/open 'x-apple.systempreferences:com.apple.Passwords-Settings.extension'"
set AutoFillFromPasswordsCheckbox to missing value
tell application "System Events" to tell process "System Settings"
repeat with i from 1 to 5
try
delay 0.5
set AutoFillFromPasswordsCheckbox to checkbox 1 of group 2 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window "AutoFill & Passwords"
if value of chkbox is 0 then
click chkbox
end if
exit repeat
end try
end repeat
if AutoFillFromPasswordsCheckbox is missing value then
tell me
activate
display dialog "Checkbox" with title "Missing" giving up after 2
end tell
end if
end tell
tell application "System Settings"
close window "AutoFill & Passwords"
end tell
end AutoFill()
I want to avoid opening the Preference pane, if the plist boolean value already registers my targeted value. In other words, if the slider is in the off position, and that is the position desired for my underling activity, then the script will avoid needlessly opening the preference pane.