Thursday, January 18, 2018
  • Index
  •  » Code Exchange
  •  » Handlers for enabling/Disabling Screen password in Mavericks

#1 2014-03-18 08:26:53 pm

McUsrII
Member
Registered: 2012-11-21
Posts: 3046
Website

Handlers for enabling/Disabling Screen password in Mavericks

Hello.

I couldn't find back to the originals, so here are handlers that works with Mavericks. I don't test for UI Elements enabled anymore. You'll have to assert that UI Elements are enabled yourself.

Applescript:

(*
[url]http://macscripter.net/viewtopic.php?pid=171773#p171773[/url]
Copyright © 2014 McUsr All Rights reserved.

UI Elments must be enabled for the script to work
*)

script disablePasswordPrompt
   tell application "System Preferences"
       tell anchor "General" of pane "com.apple.preference.security" to reveal
       activate
   end tell
   tell application id "sevs"
       set screen_lock_on to value of checkbox 1 of tab group of window 1 of application process "System Preferences" as boolean
       if screen_lock_on then
           try
               tell checkbox 1 of tab group of window 1 of application process "System Preferences" to perform action "AXPress"
           end try
           delay 0.05
           try
               tell button 2 of sheet 1 of window 1 of application process "System Preferences" to perform action "AXPress"
           end try
       end if
   end tell
   tell application "System Preferences" to quit
end script
tell disablePasswordPrompt to run

Applescript:

(*
[url]http://macscripter.net/viewtopic.php?pid=171773#p171773[/url]
Copyright © 2014 McUsr All Rights reserved.

UI Elments must be enabled for the script to work
*)

script EnablePasswordPrompt
   tell application "System Preferences"
       tell anchor "General" of pane "com.apple.preference.security" to reveal
       activate
   end tell
   tell application id "sevs"
       set screen_lock_on to value of checkbox 1 of tab group of window 1 of application process "System Preferences" as boolean
       if not screen_lock_on then
           try
               tell checkbox 1 of tab group of window 1 of application process "System Preferences" to click
           end try
       end if
   end tell
   tell application "System Preferences" to quit
end script
tell EnablePasswordPrompt to run

Last edited by McUsrII (2014-03-18 09:07:05 pm)

Offline

 
  • Index
  •  » Code Exchange
  •  » Handlers for enabling/Disabling Screen password in Mavericks

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)