Security preferences and script running in background

Hi,

I just discovered that when the (translated fron French) «Require password when the screen blanker is activated» option is checked in the Security pane of the system preferences (either 10.4.11 or 10.6.2), a script executing in background could behave not accordingly with what is expected. As an example, I have this little script:

tell application "ScreenSaverEngine" to activate
delay 10
tell application "System Events"
	sleep
end tell

If the Security option is checked the SLEEP command in this script will not execute.

So how can I have a script to fully execute if this option is checked ? I need a script to be running in background and I also need to require a password if I want to regain control of the screen after a certain period of inactivity.

Instead of checking this options, is there a way to script the locking of the screen and have my script to fully execute in background ?

Regards.

Robert

Found a solution but not the system’s problem !

I created a handler that, on certain conditions, puts my computer to sleep by scripting Power Manager (PM). PM is a great utility that can help you save energy and give more yeqars to your computer hardware. By script, PM can put my computer to sleep even if the screen saver is protected by a password, while “System Events” cannot.

Thanks to Graham Miln of Power Manager.