Solved

autoit3 - how do you disable the screensaver in xp

Posted on 2013-01-17
7
405 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
How our DevOps Teams Maximize Uptime

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

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

808 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