Solved

autoit3 - how do you disable the screensaver in xp

Posted on 2013-01-17
7
403 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

776 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