Sign in to follow this  
Followers 0
Morteza

How to disable screensaver?

6 posts in this topic

Dears, I need to disable Windows screensaver during running my AutoIt program. Is it possible? I searched the forum from top to bottom, but didn't found any answer ;-(

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Dears, I need to disable Windows screensaver during running my AutoIt program. Is it possible? I searched the forum from top to bottom, but didn't found any answer ;-(

From registry or this is an ugly code, to set [NONE] for ScreenSaver , but work:

ShellExecute("rundll32.exe","shell32.dll,Control_RunDLL desk.cpl,,1 ",@SystemDir,"",@SW_HIDE)
WinWait("Display Properties")
ControlSend("Display Properties","","ComboBox1","{PGUP}")
ControlSend("Display Properties","","ComboBox1","{ENTER}")
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Thanks for your reply, but disabling/enabling ScreenSaver by registry need a system restart and is not a good idea. As you are said, your second solution way put a scratch on the user face too.

I found a function in user32.dll for solving the problem. I hope my code be useful for other needers in features :)

; Usage : Disable/Enable Windows ScreenSaver feature
; Author: Morteza

      ;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  ;==>_ScreenSaverActive
1 person likes this

Share this post


Link to post
Share on other sites

Thanks for your reply, but disabling/enabling ScreenSaver by registry need a system restart and is not a good idea. As you are said, your second solution way put a scratch on the user face too.

I found a function in user32.dll for solving the problem. I hope my code be useful for other needers in features :)

Thanks, just what I was looking for.

Share this post


Link to post
Share on other sites

Another method might be to have your script periodically move the mouse a pixel then move it back every couple minutes.


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

I already have a script that does it.

#Include <Date.au3>
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode",1)

TraySetClick(16)
$exititem   = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"_ExitScript")
$x = 1
while 1
    sleep(1000)
    $t = _NowTime(4)
    if $x = 540 Then ;resets $x so timer is set to 9 minutes. ($x = 60 is one minute)
        $m = MouseGetPos()
        MouseMove($m[0], $m[1]+1)
        MouseMove($m[0], $m[1])
        $x = 1 
    endif   
    $x = $x+1
    if $t > "18:00" or $t = "18:00" then _ExitScript() ;after 6 PM to kill mousemove
WEnd    

func _ExitScript()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0