Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to toggle screen saver password' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to toggle screen saver password
Authored by: designr on Jun 05, '07 10:48:44AM
set talkTRIES to 0
set TRYCOUNT to 250

tell application "System Preferences"
	activate
	set frontmost to true
	tell application "System Events"
		tell application process "System Preferences"
			click menu item "Security" of menu "View" of menu bar 1
			repeat until (window "Security" exists) or (talkTRIES > TRYCOUNT)
				set talkTRIES to talkTRIES + 1
			end repeat
			tell window "Security"
				if the value of first checkbox is 0 then
					click the first checkbox
					tell application "GrowlHelperApp"
						set the allNotificationsList to {"Screensaver Setting"}
						set the enabledNotificationsList to {"Screensaver Setting"}
						register as application "AppleScript - SSPass" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "System Preferences"
						notify with name "Screensaver Setting" title "Screensaver Setting" description "The Screensaver password has been enabled." application name "AppleScript - SSPass"
					end tell
				else
					click the first checkbox
					tell application "GrowlHelperApp"
						set the allNotificationsList to {"Screensaver Setting"}
						set the enabledNotificationsList to {"Screensaver Setting"}
						register as application "AppleScript - SSPass" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "System Preferences"
						notify with name "Screensaver Setting" title "Screensaver Setting" description "The Screensaver password has been disabled." application name "AppleScript - SSPass"
					end tell
				end if
			end tell
		end tell
	end tell
	quit
end tell


Admittedly more complex but this one works.

[ Reply to This | # ]
An AppleScript to toggle screen saver password
Authored by: TemporalKnot on Jun 13, '07 06:01:40AM

Doesn't work for me. On the line:
click menu item "Security" of menu "View" of menu bar 1

I get the following error :
System Events got an error: NSReceiverEvaluationScriptError: 4

I'm running 10.4.9 with all patches.



[ Reply to This | # ]