UI Scripting Security Settings

  1. I am running this script on 10.7 and it works by toggling off disable remote and require password. First problem I am running into is to get the second part to work I have to manually unlock system preferences. Is there a way around this?

  2. Next questions is I would like to modify other parts of the security pane but I have no idea how to target them. I tried just using checkbox 3 but that did not work. What are the numbers for the other settings in the security section. I would like to turn on disable automatic login, require an admin password to access system preferences with lock icons, log out after 14 minutes of inactivity.

  3. Last questions is how do I implement an if statement to check if the box is already checked. if it is skip that box if it is not check then the script would select it. I tried a few if statements but the script just gave an error.

Example:


tell application "System Events"
	
	tell process "System Preferences"
		
		display dialog "Make sure the lock at the bottom left corner of the preference pane is unlocked. If it is not please unlock it now before running the script." with icon note
		
		click checkbox 1 of tab group 1 of window "Security & Privacy" -- disable remote --control	
		click checkbox 2 of tab group 1 of window "Security & Privacy" -- Require password
		--
		
	end tell
end tell

tell application "System Events" to tell application process "System Preferences"
	display dialog "Make sure the lock at the bottom left corner of the preference pane is unlocked. ¬ 
If it is not please unlock it now before running the script." with icon note
	
	tell window "Security & Privacy"
		
		tell tab group 1 to tell checkbox 1 to click
				
		if value of checkbox 1 of tab group 1 = 0 then
			repeat until (sheet 1 exists)
				delay 0.1
			end repeat
			tell sheet 1 to tell UI element "Turn Off Screen Lock" to click
			say "The checkbox IS UNCHECKED"
		else
			say "The checkbox IS CHECKED BACK"
		end if
		
	end tell
end tell

This has no effect now.
Activating GUI scripting is no longer achieved this way.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 8 aout 2019 10:27:35