Header Ads

How to Disable Screen saver-1 using QTP code

Here is modified code for screen saver disabling function....Credit goes to "Christian Jacob" for his beautiful code...Enjoy it
Aditi has already given the code by mouse movement 
Please read this http://www.askqtp.com/2009/02/stop-screen-lock.html


I found this solution by Christian ...I liked it. I thought to share this with you.





Dim WShShell,Value,Saved
Dim Password
'Password=Inputbox ("Enter Password")
'If Password <> "running" then Wscript.quit
Set WshShell=WScript.CreateObject("WScript.Shell")
On Error Resume Next
Value = WshShell.RegRead("HKCU\Control Panel\Desktop\ScreenSaveActive")
Saved = WshShell.RegRead("HKCU\Control Panel\Desktop\SaveScreenSaved")
Err.Clear
'MsgBox Value & "-" & Saved
On Error Goto 0
If Saved <> "1" then
WSHShell.RegWrite "HKCU\Control Panel\Desktop\SaveScreenSave",Value
WSHShell.RegWrite "HKCU\Control Panel\Desktop\SaveScreenSaved","1"
WshShell.RegWrite "HKCU\Control Panel\Desktop\ScreenSaveActive","0"
end if
WScript.Quit(0)
and this restores it...
'::Title Restore Saved Screen Saver
'::Version 0 - Date 05 Nov 2000
Option Explicit
Dim WShShell,Value,Saved
Set WshShell=WScript.CreateObject("WScript.Shell")
On Error Resume Next
Value = WshShell.RegRead("HKCU\Control Panel\Desktop\SaveScreenSave")
Saved = WshShell.RegRead("HKCU\Control Panel\Desktop\SaveScreenSaved")
Err.Clear
'MsgBox Value & "-" & Saved
On Error Goto 0
If Saved = "1" then
WSHShell.RegWrite "HKCU\Control Panel\Desktop\ScreenSaveActive",Value
WSHShell.RegWrite "HKCU\Control Panel\Desktop\SaveScreenSaved","0"
end if
WScript.Quit(0)



Hope you like it too.
Powered by Blogger.