Solved

autoit3 - how do you disable the screensaver in xp

Posted on 2013-01-17
7
407 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to count occurrences of each item in an array.

733 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