Weird ... or misunderstood !

Hi,

do shell script "/bin/sleep 15"
tell application "System Events"
	sleep
say "hello"
end tell

If I execute this script and activate the screen saver with the hot corner before the sleep command executes, the «sleep» statement does not execute but the «say» does.

If I execute it alone the sleep command executes according to what is expected.

What am I misunderstanding ? Regards.

Robert

Probably nothing, you just confused it.

Just try it … Execute the script, activate the screen saver with the hot corner and see if the sleep command executes …

Or simpler try this:

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

On my computer, the sleep command never executes !!!

Model: iMac Intel (10.6.2) + iMac G5 (10.4.11)
AppleScript: 2.3 + 2.1.1
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

It works fine.

This script worked fine in many other script … If I execute it without the «tell application “ScreenSaverEngine” to activate» statement, it works … with it, it does not work.

What could be interfering ?

Model: iMac Intel (10.6.2) + iMac G5 (10.4.11)
AppleScript: 2.3 + 2.1.1
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

I would have said timing and (if AS does it) expectations, but not working with tell to activate??? Weird. An example of another script with this like you said?

Hopefully not … I tried it on my new Intel machine and I get the same result. There must be a configuration interfering somewhere !!!

:(:(:(:(:frowning:

You say you have other scripts that behave weirdly but differently, can you paste one?

There is no other script behaving strangly. I said that I tried the same script on my Intel machine and that I got the same result.

Anyway, I think I found the culprit … In the «Security» pane of the System Preferences, there is an option (translated from French) to «Require a password if the screen saver is activated». Could you check that option and retry the script «with» the screen saver activation statement and see if you get the same result …

Thanks for helping …

Or have I misunderstood? “many other”

The little script worked well when embedded in other scripts … but that was before the Security option was checked.

Does that mean that with that Security option checked scripts cannot execute correctly in background ?

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.