Screensaver Enable/Disable

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Screensaver Enable/Disable

Post by JRL » Fri Nov 11, 2005 8:27 pm

Screensaver Enable/Disable

I was having a problem with a script that has a dialog that remains open perpetually. If the script was running, the screensaver would not come on. In my mind there's only one reason to use a screensaver and that's for the security provided by password protection. Obviously if the screensaver doesn't come on, there is no security on that computer.

After a little investigation, I found that screensaver defeating is intensionally built into Macro Scheduler. This information is from the next to last paragraph of the help file for "Scheduling Scripts". It says:
"...Macro Scheduler temporarily disables screensaving just before it runs a script and re-enables screensaving when the script completes."

This makes some sense, if you have a macro that is working as a mouse/keyboard replacement, the macro could fail if the screensaver comes on. However, I have several scripts with dialog boxes that allow users to enter then process information. The dialog may stay active all day and I want the screensaver to be invoked if the user is away from his/her computer for an extended time period.

So I contacted support and as usual, their response was outstanding. They sent me the following:



//re-enable screensaver:
LibFunc>user32,SystemParametersInfoA,r,17,1,0,0
//disable screensaver:
LibFunc>user32,SystemParametersInfoA,r,17,0,0,0




You must be running version 7.3.10 or later to use the LibFunc command.

Note the only difference between these two lines is the third character from the right (excluding commas). If that character is a "1" and this line is called in your script, the screen saver will function normally even though the script continues to be running.

It is important to note that a script can still prevent the screensaver from invoking. Mouse moves sent by a script, windows opened by a script and windows focused by a script are three things I have tested that will prevent a screensaver even though the script executed a LibFunc line that would enable the screensaver.

I see from this thread: http://www.mjtnet.com/forum/viewtopic.php?t=2354 that the next version of Macro Scheduler will include control over screen locking and unlocking. Perhaps this functionality will also impact the screensaver enable/disable while a script is running. If so, this advice may be superceeded soon.

Hope that you found this useful,
Dick

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Fri Nov 11, 2005 10:22 pm

If someone is stuck with an earlier version of MS, here's an alternative method to enable / disable the screen saver:

//Disable
RegistryWriteKey>HKEY_CURRENT_USER,Control Panel\Desktop,ScreenSaveActive,0
//Enable
RegistryWriteKey>HKEY_CURRENT_USER,Control Panel\Desktop,ScreenSaveActive,1
Best Wishes,
Monkster

User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Nov 11, 2005 11:25 pm

Actually, I don't think the method you're employing is the same thing. I think your method is turning the screensaver on or off just as if it was done manually. The difference being that even if the screensaver is turned on, Macro Scheduler is designed to prevent it from invoking while a script is running. The LibFunc enable method will allow the screensaver to invoke while the script is running.

Hope this makes sense,
Dick

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Sat Nov 12, 2005 12:54 am

Thanks for the explanation JRL, now I get it.

SPI_SETSCREENSAVEACTIVE ("17") will allow the script to continue running AND let the screen saver invoke itself. Very cool!

You could start the screensaver for the user as well.

LibFunc>user32,SystemParametersInfoA,r,15,5,0,0

2nd param ("15") calls SPI_SETSCREENSAVETIMEOUT and the 3rd param ("5") sets the number of seconds until the screensaver kicks in.

This one would be fun on April 1st:
LibFunc>user32,SystemParametersInfoA,r,15,1,0,0
:lol:
Best Wishes,
Monkster

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Mon Nov 14, 2005 3:46 am

Great Post A Lot Of Helpful Information There.
FIREFIGHTER

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts