Solved

autoit3 - how do you disable the screensaver in xp

Posted on 2013-01-17
7
401 Views
Last Modified: 2013-01-17
i'm trying to disable the screensaver temperally so my script can run. I'm not having sucess with disabling the screensaver. Please help.
Here is the code i have tried.

method one:
runwait("reg add", '"HKCU\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 0 /f')

Open in new window


method two:
 ;Disable Windows ScreenSaver
	   _ScreenSaverActive(False)

	  Sleep(10000)

	 ;Enable Windows ScreenSaver
	  ; _ScreenSaverActive(True) 

Func _ScreenSaverActive($bBoolean)
	Local Const $SPI_SETSCREENSAVEACTIVE = 17
	Local $lActiveFlag
	
	Dim $lActiveFlag
	Dim $retvaL
	
	If $bBoolean Then
		$lActiveFlag = 1
	Else
		$lActiveFlag = 0
	EndIf
	
	$dll = DllOpen("user32.dll")
	$retvaL = DllCall($dll, "long", "SystemParametersInfo", "long", $SPI_SETSCREENSAVEACTIVE, "long", $lActiveFlag, "long", 0, "long", 0)
	DllClose($dll)
EndFunc 

Open in new window


thanks!!!
0
Comment
Question by:TechyT
  • 5
  • 2
7 Comments
 
LVL 8

Expert Comment

by:H
ID: 38788328
shell "Regchg Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive\REG_DWORD 0"
0
 
LVL 8

Expert Comment

by:H
ID: 38788333
here is the shellexecute details

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

http://www.autoitscript.com/autoit3/docs/functions/ShellExecute.htm
0
 

Author Comment

by:TechyT
ID: 38788340
regchng gives me not recognized as an internal or external command.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 8

Expert Comment

by:H
ID: 38788343
examples to try

ShellExecute("Regchg", "Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveActive\REG_DWORD 0")

let me know if you need help? I haven't tested the autoit part...just the reg change part works great.
0
 
LVL 8

Accepted Solution

by:
H earned 500 total points
ID: 38788360
try:

Reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v ScreenSaveActive /t REG_SZ /d 0 /f
0
 
LVL 8

Expert Comment

by:H
ID: 38788394
also you can create a text file and call it something like

SisableScr.reg

put this in file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]
"ScreenSaveActive"="0"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"NoDispScrSavPage"=-


then your shell command would be:

regedit /s "SisableScr.reg"
0
 

Author Closing Comment

by:TechyT
ID: 38788869
this actually worked i had the ''s coded wrong the correct method that worked for me was like this
; Usage : Disable/Enable Windows ScreenSaver feature


	  ;Disable Windows ScreenSaver
	   _ScreenSaverActive(False)

	  Sleep(10000)

	 ;Enable Windows ScreenSaver
	  ; _ScreenSaverActive(True) 

Func _ScreenSaverActive($bBoolean)
	
	If $bBoolean Then
		$command = 'REG ADD "HKCU\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 0 /f'
		$command2 = 'REG ADD "HKCU\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 0 /f' ;was 600
	Else
		$command = 'REG ADD "HKCU\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 1 /f'
		$command2 = 'REG ADD "HKCU\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 600 /f' 
	EndIf
	
	RunWait($command)
	RunWait($command2)
EndFunc  ;==>_ScreenSaverActive

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now