Jump to content

Script does not deactivate screensaver (Windows 8.1)


Recommended Posts

I have a very basic script:

MouseClick("left",1196,15,1)
MouseClick("left",1202,19,1)

And, this script runs just fine, so long as the screen saver is not active. However, if the computer is in screensaver mode, I do not have a way to close the screen saver from within an autoit script.

I have tried launching a program to deactivate the screen saver:

RunWait(@COMSPEC & " /c Dir C:\")

And, I've tried scripting combinations of mouse moves and clicks, but no scripting that I have found can deactivate the active screensaver in Windows 8.1.

Any help would be greatly appreciated.

Let me preemptively stop the comments, "Check the forums." I've tried many search combinations, and I've read about 15 threads related to the screen saver and autoit: none of which dealt with waking a computer from screen saver. Most of the threads are for preventing a screen saver from becoming active while the script is running. So, yes, I have spent about 45 minutes researching this, and I cannot find an answer. Additionally, I asked an expert autoit programmer, and he did not have an answer either.

Link to comment
Share on other sites

I found a couple of scripts to disable the screensaver. Here is one of them, but on my machine, the screen saver stays active even as the script is running (and presumably not doing anything).

Func _Au3RecordSetup()
    Opt('WinWaitDelay',100)
    Opt('WinDetectHiddenText',1)
    Opt('MouseCoordMode',0)
EndFunc
Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
_AU3RecordSetup()

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


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

Sleep(65000);

  ;Disable Windows ScreenSaver
   _ScreenSaverActive(False)

MouseClick("left",1196,15,1)
      Sleep(10000)

 ;Enable Windows ScreenSaver
   _ScreenSaverActive(True)
RunWait(@COMSPEC & " /c Dir C:\")

Sleep(50000);
MouseClick("left",1196,15,1)
MouseClick("left",1202,19,1)
Link to comment
Share on other sites

Final post: I have decided to live without a screensaver. Instead, the monitor will simply turn off after a predetermined time. The autoit script has no trouble waking a turned off monitor... It only has a problem waking an active screensaver.

This solution is probably better for the environment anyhow. Time to grow up and say good-bye to the screen saver.

Link to comment
Share on other sites

  • 1 year later...

To resurrect an old thread, which was the first I found when looking for the answer, I made the following to deactivate the saver on Win8.1. Maybe useful for others...

#include <File.au3>

func KillScreenSaver()
    local $szDrive, $szDir, $szFName, $szExt
    $sspath=RegRead("HKCU\Control Panel\Desktop","SCRNSAVE.EXE")
    if @error<>0 then return 0
    _PathSplit($sspath, $szDrive, $szDir, $szFName, $szExt )
    $SCRproc=$szFName &  $szExt
    if ProcessExists($SCRproc) Then
        processclose($SCRproc)
        ProcessWaitClose($SCRproc,1)
    EndIf
EndFunc

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...