Solved

autoit3 - how do you disable the screensaver in xp

Posted on 2013-01-17
7
394 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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

16 Experts available now in Live!

Get 1:1 Help Now