Script to turn on/off Screen Saver

Script to turn on/off Screen Saver

Post by Trevo » Mon, 13 Nov 2006 10:45:36


Hi.

Is there an availaible script that I can run which would toggle
between my default screen saver from the on state to the off state?
Would really like to have one on my desktop to turn it off and on at
will.

Thanks,


Respectfully,

Trev
 
 
 

Script to turn on/off Screen Saver

Post by Dave Patri » Mon, 13 Nov 2006 10:54:25

You can use RegWrite method to toggle the Reg_Sz string 'ScreenSaveActive'
from 1 to 0
found at;
HKEY_CURRENT_USER\Control Panel\Desktop

then;
using the Run method;
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.yqcomputer.com/


| Hi.
|
| Is there an availaible script that I can run which would toggle
| between my default screen saver from the on state to the off state?
| Would really like to have one on my desktop to turn it off and on at
| will.
|
| Thanks,
|
|
| Respectfully,
|
| Trev

 
 
 

Script to turn on/off Screen Saver

Post by Bluesk » Mon, 13 Nov 2006 17:59:29

Dim WSHShell
Set WSHShell=Wscript.CreateObject("Wscript.Shell")

state = WSHShell.RegRead("HKEY_CURRENT_USER\Control
Panel\Desktop\ScreenSaveActive")

If state =0 then
WSHShell.RegWrite "HKEY_CURRENT_USER\Control
Panel\Desktop\ScreenSaveActive", "1"
else
WSHShell.RegWrite "HKEY_CURRENT_USER\Control
Panel\Desktop\ScreenSaveActive", "0"
End IF
 
 
 

Script to turn on/off Screen Saver

Post by Trevo » Tue, 14 Nov 2006 01:20:27

This is what <Bluesky> shared with us today ...


Hi Bluesky,

It works Great. Thank you very much.
Now I'll try my hand at adding a pop-up window
that says "ScrnSave ON" or "ScrnSave OFF" depending on the value of
"state"

Thanks Again !

Respectfully,

Trev
 
 
 

Script to turn on/off Screen Saver

Post by Dave Patri » Tue, 14 Nov 2006 01:27:39

It won't take effect until you;

a) logoff/logon
b) RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.yqcomputer.com/


| This is what <Bluesky> shared with us today ...
|
| >Dim WSHShell
| >Set WSHShell=Wscript.CreateObject("Wscript.Shell")
| >
| >state = WSHShell.RegRead("HKEY_CURRENT_USER\Control
| >Panel\Desktop\ScreenSaveActive")
| >
| >If state =0 then
| > WSHShell.RegWrite "HKEY_CURRENT_USER\Control
| >Panel\Desktop\ScreenSaveActive", "1"
| >else
| > WSHShell.RegWrite "HKEY_CURRENT_USER\Control
| >Panel\Desktop\ScreenSaveActive", "0"
| >End IF
|
| Hi Bluesky,
|
| It works Great. Thank you very much.
| Now I'll try my hand at adding a pop-up window
| that says "ScrnSave ON" or "ScrnSave OFF" depending on the value of
| "state"
|
| Thanks Again !
|
| Respectfully,
|
| Trev
 
 
 

Script to turn on/off Screen Saver

Post by Trevo » Tue, 14 Nov 2006 01:51:32

This is what <Dave Patrick> shared with us today ...


Hi Dave,

I'm not sure where I would add that line in the code from BlueSky.
However, his example is working without loggin off/on.
What I noticed though is, even though it works, The ScreenSaver
Display properties remains unchanged making it appear that that it's
not toggling. I set my screen saver timeout to 1 minute with password
protection to test it and it seems to work fine both in the "On" and
"Off" states.


Respectfully,

Trev
 
 
 

Script to turn on/off Screen Saver

Post by Dave Patri » Tue, 14 Nov 2006 02:12:39

You may have another unique issue that's making it work. Such as the shell
is being restarted. I wouldn't rely on it working that way.

You can use the Run method to call the DLL function I mentioned.

Get the documentation here.
http://www.yqcomputer.com/


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.yqcomputer.com/


| Hi Dave,
|
| I'm not sure where I would add that line in the code from BlueSky.
| However, his example is working without loggin off/on.
| What I noticed though is, even though it works, The ScreenSaver
| Display properties remains unchanged making it appear that that it's
| not toggling. I set my screen saver timeout to 1 minute with password
| protection to test it and it seems to work fine both in the "On" and
| "Off" states.
|
|
| Respectfully,
|
| Trev