Jump to content

Keep Screensaver Off


Recommended Posts

Some thoughts:

1. Monitor how long the console has been idle with _Timer_GetIdleTime()

2. Only twitch the mouse when you have to, if idle time is getting too high

3. Only twitch it a tiny amount (one, or a couple of pixels X/Y)

4. Immediately put the mouse back to the coordinate it was at before, saved with MouseGetPos()

This may all be moot if there is a DLL trick to reset the idle timer (no twitching would be required), but I never looked for it, so I don't know if there is one or not.

:blink:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Does anyone have a quick little script to keep the screensaver from activating?

I was just going to do some quick dumb script that moves the mouse every few seconds. But then i got to wondering if there was a better way to do it.

Searching the forums didn't really turn anything up, but I can't help but think that someone has done this before and posted about it.

Link to comment
Share on other sites

Here's one I've used while watching long online videos, almost exactly like PsaltyDS says. You can set the $idle_limit to anything as long as its less than the time you've set for a screensaver, and just hit BACKSPACE to disable it when you don't need it anymore.

#include <Date.au3>
;===============================================================================
; Description:      Moves mouse periodically to prevent screen saver
;===============================================================================
$idle_limit = 2 * 60 * 1000; 2 minutes * 60 sec * 1000 msec (should set this to less than screensaver time)
$offset = 1 ; how far to move the mouse
;===============================================================================
; MAIN
;===============================================================================
HotKeySet("{BACKSPACE}", "done")
While 1
    If _Get_Idle_Ticks() > $idle_limit Then
        $mouse = MouseGetPos()
        MouseMove($mouse[0] + $offset, $mouse[1] + $offset)
        $offset = -$offset
    EndIf
    Sleep(100)
WEnd

;===============================================================================
; Description:
; Parameter(s):
; Requirement(s):   None
; Return Value(s):
; Note(s):
;===============================================================================
Func done()
    HotKeySet("{BACKSPACE}")
    Send("{BACKSPACE}") ; Backspace is passed through in case user forgets to disable the script
    Exit
EndFunc


;===============================================================================
; Description:      Returns number of ticks since system was idle (determined by mouse/key input)
; Parameter(s):     None
; Requirement(s):   None
; Return Value(s):  Milliseconds since last user input (mouse/key)
; Note(s):
;===============================================================================
Func _Get_Idle_Ticks()
    Local $struct = DllStructCreate("uint;dword");
    DllStructSetData($struct, 1, DllStructGetSize($struct));
    DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct))
    Local $last_active = DllStructGetData($struct, 2)
    Return _Date_Time_GetTickCount() - $last_active
EndFunc
Link to comment
Share on other sites

I use this to disable the screensaver with a registry entry. And prevent GPO from refreshing the policies until I have finished running a script.

RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop","ScreenSaveActive", "REG_SZ", "0")
RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop","ScreenSaverIsSecure", "REG_SZ", "0")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Group Policy\{A2E30F80-D7DE-11d2-BBDE-00C04F86AE3B}","NoBackgroundPolicy", "REG_DWORD", "1")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Group Policy\{A2E30F80-D7DE-11d2-BBDE-00C04F86AE3B}","NoGPOListChanges", "REG_DWORD", "1")
Link to comment
Share on other sites

I did exactly what you suggested about a year ago and created a script that moves the cursor back and forth a couple of pixels every few minutes. May not be the most well written script you've ever seen but it works great for me. Even puts a little tray icon for you to pause it when needed. I run it all day.

TraySetIcon ("Shell32.dll", 28)
TraySetToolTip ("Screen Saver Terminator" & @CRLF & "Moves mouse every couple of minutes to prevent machine from going idle.")

While 1

    $x = MouseGetPos (0)
    sleep (120000)
    $Current = MouseGetPos (0)
    
    If $Current = $x Then
        $y = MouseGetPos (1)
        MouseMove ($Current + 20, $y, 5)
        MouseMove ($x, $y, 5)
    EndIf
    
WEnd
Link to comment
Share on other sites

Just toggle it on and off. Heres a user's contribution: Setting Screen Saver

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...