Disengaging screensavers from script?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Disengaging screensavers from script?
Does anyone know of a way to 'wake' from a screensaver/energy saver using script?
The situation is such that I can't (a) expect the user to wake it manually via mouse or keyboard, and (b) I can't modify the user's screensaver preferences.
My first thought was wiggling the mouse using screenMouseLoc, but that doesn't work on either Mac or Windows. I found some VB scripts that Rev could theoretically execute that might solve my problem on Windows, but I'm still stuck on the Mac.
Any ideas?
The situation is such that I can't (a) expect the user to wake it manually via mouse or keyboard, and (b) I can't modify the user's screensaver preferences.
My first thought was wiggling the mouse using screenMouseLoc, but that doesn't work on either Mac or Windows. I found some VB scripts that Rev could theoretically execute that might solve my problem on Windows, but I'm still stuck on the Mac.
Any ideas?
Re: Disengaging screensavers from script?
Hi hwbehrens,
put this into a field or custom property:
try
tell application id "com.apple.ScreenSaver.Engine" to quit
end try
and then "do" this string as AppleScript
Just tested with a button and works:
Best from germany
Klaus
put this into a field or custom property:
try
tell application id "com.apple.ScreenSaver.Engine" to quit
end try
and then "do" this string as AppleScript

Just tested with a button and works:
Code: Select all
on mouseUp
send "do_as" to me in 5 secs
## So I have time to activate that thing :-)
end mouseUp
command do_as
do fld 1 as "AppleScript"
end do_as
Best from germany
Klaus
Re: Disengaging screensavers from script?
Excellent, thanks!
Re: Disengaging screensavers from script?
I'm actually having trouble getting this to work on 10.6.7. Which version are you running the example on?
Re: Disengaging screensavers from script?
Hi hw,
did you put
Maybe you rename the field and call it by name in the button script. Should work.
Klaus's beautiful script works right away for me on MacOSX 10.6.7
Kind regards
Bernd
did you put
into the only field on the card? Or the field with the lowest layer?try
tell application id "com.apple.ScreenSaver.Engine" to quit
end try
Maybe you rename the field and call it by name in the button script. Should work.
Klaus's beautiful script works right away for me on MacOSX 10.6.7
Kind regards
Bernd
Re: Disengaging screensavers from script?
Yes, as far as I can tell, everything is correct. I have a beep just above the "do as ..." line, so I know it's getting to it, but it's not actually exiting the screensaver.
I am triggering the screensaver using the Test button the Desktop & Screen Saver prefpane. Are you doing the same, or using Hot Corners?
EDIT: Yes, I tried it with Hot Corners and it works. Apparently the "Test" button invokes the screensaver in such a way that the script doesn't work properly.
EDIT 2: Okay, here is an alternative Applescript that works for normally-invoked and Test-invoked screensavers as well as for displays which have gone to sleep:
Certainly not as clean or elegant, but it gets the job done. Key code 59 is CTRL, so it doesn't pollute any of my fields with errant characters thankfully.
I am triggering the screensaver using the Test button the Desktop & Screen Saver prefpane. Are you doing the same, or using Hot Corners?
EDIT: Yes, I tried it with Hot Corners and it works. Apparently the "Test" button invokes the screensaver in such a way that the script doesn't work properly.
EDIT 2: Okay, here is an alternative Applescript that works for normally-invoked and Test-invoked screensavers as well as for displays which have gone to sleep:
Code: Select all
try
tell application "System Events" to key code 59
end try
Re: Disengaging screensavers from script?
I'm still struggling with the VBScript implementation. From what I can tell, I need to use the following command:
However, because I have no experience with VBScript at all, I'm not even sure if that's a valid command. Do I need to wrap it in a function name? I just keep getting execution errors as my 'do' result...
Code: Select all
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 1);
Re: Disengaging screensavers from script?
That doesn't look at all like VBScript - either C++ or C# I think.
The problem with waking from screensaver is that many systems will be set to lock when the screensaver triggers. On waking, the login screen will be presented, causing the user to manually rejoin the logged in session.
The best I can suggest is this: http://blogs.technet.com/b/heyscripting ... rting.aspx
to prevent the screensaver kicking in in the first place.
The problem with waking from screensaver is that many systems will be set to lock when the screensaver triggers. On waking, the login screen will be presented, causing the user to manually rejoin the logged in session.
The best I can suggest is this: http://blogs.technet.com/b/heyscripting ... rting.aspx
to prevent the screensaver kicking in in the first place.
Re: Disengaging screensavers from script?
Yeah, I realize what I'm trying to do is not an ideal solution. I'm not as worried about the password prompt, as that would imply that they have a mouse and/or a keyboard attached. However, many of our users are running our software as a kiosk without any form of (traditional) input attached.
If they forget to disable their screensaver during the initial installation, they won't be able to get out of it once it starts without connecting a keyboard or mouse.
Ideally, the software would honor their screensaver settings and wake only at predetermined times (when the software receives input over a socket, for example), but if the only solution is to disable the screensaver completely, that will be better than what we have today.
If they forget to disable their screensaver during the initial installation, they won't be able to get out of it once it starts without connecting a keyboard or mouse.
Ideally, the software would honor their screensaver settings and wake only at predetermined times (when the software receives input over a socket, for example), but if the only solution is to disable the screensaver completely, that will be better than what we have today.
Re: Disengaging screensavers from script?
After reading the article, it seemed as if these lines are what actually wake the computer:The best I can suggest is this: http://blogs.technet.com/b/heyscripting ... rting.aspx
Code: Select all
Set objIE = CreateObject("InternetExplorer.Application")
Wscript.Sleep 1000
objIE.Quit
Re: Disengaging screensavers from script?
From the dictionary under "do"
A recent thread http://forums.runrev.com/phpBB2/viewtop ... 000#p35000 showed the technique in action.
So you could handle this in an alternative manner by having the vbscript file saved externally to the Livecode application, and use the 'get shell' method of execution and result retrieval.Any scripts on Windows which contain references to WScript will fail to run as WScript objects do not exist in the LiveCode Environment. Return values should therefore be placed within the global result variable instead of using WScript.Echo.
A recent thread http://forums.runrev.com/phpBB2/viewtop ... 000#p35000 showed the technique in action.
Re: Disengaging screensavers from script?
Thanks for the tip! I'm not sure how I missed that. I am going to see if I can find a solution that doesn't require WScript objects first so I can continue to use the 'do as' method, but if I don't have any luck, I'll definitely go with the local vbs execution method.
Thanks again!
Thanks again!