Jump to content

KillSaver


TomTheGeek
 Share

Recommended Posts

This is a little program I wrote for all of you that are using a corporate computer system at work that forces a screensaver lockout on you. Just a simple little script that moves the mouse every so often (but only if the mouse is idle) so the screensaver doesn't kick in.

The code is below, and I attached the compiled version, just unzip into your favorite location (I suggest the startup menu) and run.

Any feedback or suggestions would be appreciated!!

Opt("GuiOnEventMode",1)
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1); no default tray menuitems
#NoTrayIcon
#include <GUIConstants.au3>

Global $infolabel
Global $sleepTime
Global $pause = 1

;---------------Tray event values----------------

Global $TRAY_EVENT_SHOWICON         = -3
Global $TRAY_EVENT_HIDEICON         = -4
Global $TRAY_EVENT_FLASHICON        = -5
Global $TRAY_EVENT_NOFLASHICON      = -6
Global $TRAY_EVENT_PRIMARYDOWN      = -7
Global $TRAY_EVENT_PRIMARYUP        = -8
Global $TRAY_EVENT_SECONDARYDOWN    = -9
Global $TRAY_EVENT_SECONDARYUP      = -10
Global $TRAY_EVENT_MOUSEOVER        = -11
Global $TRAY_EVENT_MOUSEOUT         = -12
Global $TRAY_EVENT_PRIMARYDOUBLE    = -13
Global $TRAY_EVENT_SECONDARYDOUBLE  = -14
    
;---------------Build UI----------------
TraySetClick(16)

$runitem = TrayCreateItem("Set Timeout")
TrayItemSetOnEvent(-1,"SetTimeout")
TrayCreateItem("")
$infoitem = TrayCreateItem("About")
TrayItemSetOnEvent(-1,"DisplayAbout")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitEvent")

TraySetIcon(@AutoItExe)

TraySetState()
TraySetToolTip("KillSaver 1.2")

;---------------Set initial variables----------------

$lastpos = MouseGetPos()
$PreviousSetting = RegRead("HKEY_CURRENT_USER\SOFTWARE\KillSaver\", "Timeout")
If $PreviousSetting <> "" Then
    $sleepTime = $PreviousSetting
Else
    $sleepTime = 1000 * 60 * 5;Five minutes = 1000 * 60 * 5
EndIf


;---------------Main loop----------------

While 1
    $currentpos = MouseGetPos()
   ;Check if current position is the same as the last position, if true move the mouse to the right.
    if $lastpos[0] = $currentpos[0] AND $lastpos[1] = $currentpos[1] then
        MouseMove($currentpos[0] + 50, $currentpos[1], 4)
        
       ;Check to see if the mouse has actually moved, move the mouse to the left if not.
        $newpos = MouseGetPos()
        if $lastpos[0] = $newpos[0] AND $lastpos[1] = $newpos[1] then
            MouseMove($currentpos[0] - 50, $currentpos[1], 4)
        endif
        
       ;Move back to original position so the mouse is in the same place they left it.
        MouseMove($currentpos[0], $currentpos[1], 4)
    EndIF
   ;MsgBox(48,"",$sleepTime)
    Sleep($sleepTime)
    $lastpos = $currentpos
WEnd

Exit

;---------------Functions----------------

;Dialog for setting loop timout.
Func SetTimeout()
    GUICreate("Set Timout", 210, 100)
    GUISetIcon(@AutoItExe)
    
    $Label = GUICtrlCreateLabel("Enter a timeout value" & @CRLF & "(in minutes)", 20, 15, 100, 30)

    $inputID = GUICtrlCreateInput ($sleepTime/60/1000, 150, 17, 50, 20)
    $timeoutID = GUICtrlCreateUpdown ($inputID, $UDS_ARROWKEYS)
    GUICtrlSetLimit ( $timeoutID, 9999, 1)
    
    $SaveID  = GUICtrlCreateButton("Save", 40, 70, 50, 20)
    GUICtrlSetOnEvent($SaveID,"OnSave")
    
    $CancelID = GUICtrlCreateButton("Cancel", 120, 70, 50, 20)
    GUICtrlSetOnEvent($CancelID,"OnClose")
    
    GUISetOnEvent($GUI_EVENT_CLOSE,"OnClose")
    
    GUISetState() ; display the GUI
EndFunc

;Display about dialog box
Func DisplayAbout()
    GUICreate("About", 250, 180)
    GUISetIcon(@AutoItExe)
    
    GUICtrlCreateIcon(@AutoItExe, -1, 5, 7)
    GUICtrlCreateLabel("KillSaver Version 1.2" & @CRLF & "by Tom Beighley", 50, 10, 190, 30)
    GUICtrlCreateLabel("An application that moves the mouse when idle to disable the screen saver." & @CRLF & "Does not need Admin rights to install or run.", 50, 45, 190, 50)
    GUICtrlCreateLabel("TomTheGeek@gmail.com" & @CRLF & "www.TomTheGeek.com", 50, 105, 190, 30)
        
    $OkID = GUICtrlCreateButton("OK", 100, 150, 50, 20)
    GUICtrlSetOnEvent($OkID,"OnClose")
    
    GUISetOnEvent($GUI_EVENT_CLOSE,"OnClose")
    
    GUISetState() ; display the GUI
EndFunc

;Save settings 
Func OnSave()
    $Timeout = Number(ControlGetText("Set Timout", "", "Edit1"))
    If $Timeout > 0 Then
        $sleepTime = $Timeout * 60 * 1000
       ;MsgBox(48,"",$sleepTime)
        RegWrite("HKEY_CURRENT_USER\SOFTWARE\KillSaver\", "Timeout", "REG_DWORD", $sleepTime)
        GUIDelete()
    Else
        MsgBox(48,"Incorrect Data","Please enter non-zero numerical data only for the timeout value.")
    EndIF
EndFunc

;Function for exiting the app
Func ExitEvent()
    Exit
EndFunc

;Close last GUI window
Func OnClose()
    GUIDelete()
EndFunc

KillSaver.zip

www.TomTheGeek.com - All the geeky stuff that gets me hot
Link to comment
Share on other sites

Link to comment
Share on other sites

Maybe a stupid question, but why put all this work into making a screensaver not come up? Wouldn't it be a lot easier to just turn off your screen saver?

Link to comment
Share on other sites

You can't turn it off.  If you are logged into a domain, a group policy can be set to deny access to the desktop properties.

-John

<{POST_SNAPBACK}>

So fix the group policy to allow the screen saver to be disabled.

I'm just saying that why not go to the root source of the problem instead of trying to write a program to work around it?

Link to comment
Share on other sites

Some companies do not want you to change it. It is their computer and you are just a simple end-user who must conform to their computer usage policy.

For example, our systems are locked down tight. No changing background or screensaver, no right-clicking on My Computer, no access to C: from My Computer (all data is saved to the network share), minimal internet explorer options, no ability to install software, no Start -> Run, no games, no control panel, etc.

-John

Link to comment
Share on other sites

  • 2 weeks later...

Some companies do not want you to change it.  It is their computer and you are just a simple end-user who must conform to their computer usage policy. 

For example, our systems are locked down tight.  No changing background or screensaver, no right-clicking on My Computer, no access to C: from My Computer (all data is saved to the network share), minimal internet explorer options, no ability to install software, no Start -> Run, no games, no control panel, etc.

-John

<{POST_SNAPBACK}>

My company is like that, but there are several work arounds which you could do to kill it at the source. You could as was suggested above set the timer to -1 (i think 0 would work too), you could change it in the registry to disable the screensaver completely, etc etc. i will code an example or two and post when it's done.
Link to comment
Share on other sites

My company is like that, but there are several work arounds which you could do to kill it at the source.  You could as was suggested above set the timer to -1 (i think 0 would work too), you could change it in the registry to disable the screensaver completely, etc etc.  i will code an example or two and post when it's done.

<{POST_SNAPBACK}>

ok, got it... we have win2k at work, so that's the only thing i could test it on, but it worked for me. realized after my last post how old this thread was... oops... oh well here's the code anyway...and changing registry values works regardless of group policy etc...(i test all of the new images my work uses to TRY to lock stuff down.)

$KILL = RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop\","SCRNSAVE.EXE","REG_SZ","")

IF $KILL = 1 THEN

MSGBOX(0,"SUCCESS","SCREENSAVER KILLED")

ELSE

MSGBOX(0,"FAIL","SCREENSAVER NOT KILLED")

ENDIF

Edited by cameronsdad
Link to comment
Share on other sites

Wait a second your company will not let you change display settings but they allow you edit the registry?

<{POST_SNAPBACK}>

i test the images for the machines for security, so i have alot of freedom to do what i want with the computers. i'm not in IT or anything, i just help them out. so far they haven't made an image that i couldn't get through in under 10 minutes (usually under 1) without having to use autoit or vba.
Link to comment
Share on other sites

i test the images for the machines for security, so i have alot of freedom to do what i want with the computers.  i'm not in IT or anything, i just help them out.  so far they haven't made an image that i couldn't get through in under 10 minutes (usually under 1) without having to use autoit or vba.

<{POST_SNAPBACK}>

and with something like disabling a screensaver, how are they going to know that it's disabled unless they sit there and watch it for 10-15 minutes to make sure that noone is doing anything? for all they know, yours just never comes on because you're never away from your computer for more than 10 minutes at a time...
Link to comment
Share on other sites

There's no such thing as an online game that doesn't have the option to turn off the idle quit thing.

<{POST_SNAPBACK}>

sure there is. matrix online has an inactivity timer that you can't configure in the options. typically the screensaver won't come up while the game is on anyway, but if you're away too long it will exit out on you
Link to comment
Share on other sites

There's no such thing as an online game that doesn't have the option to turn off the idle quit thing.

<{POST_SNAPBACK}>

Diablo II has that also.
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

  • 2 weeks later...

I work at a government branch and it's required to have the screen saver lockout set using group policy and there's nothing we can do. Since I work in the IT dept I could change it, but then I would get fired. :)

I hadn't thought about changing the registry, but I'm guessing it wouldn't work since the users don't have admin privilages. That would be a slick way of fixing it though, I will try cameronsdad's code and see if it works.

I am working on a some changes to this program, mostly how the timer works and possibly adding some more user configurable options. Even if this is a useless program it was a good learning experiance, I got to play around with autoit's GUI and learned how to setup a tray bar app with a right click menu so it wasn't a total waste.

www.TomTheGeek.com - All the geeky stuff that gets me hot
Link to comment
Share on other sites

I work at a government branch and it's required to have the screen saver lockout set using group policy and there's nothing we can do. Since I work in the IT dept I could change it, but then I would get fired.  :)

O.K., with your script you are actively circumventing the IT policy. Why do you think you could get fired for changing the group policy and not for "disabling" it by running your script??

I guess, there is a reason for your policy....

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Mainly because I am only circumventing the IT policy on one computer at a time and not the entire domain. Also, this way I'm not breaking the rules, just sort of bending them. The GP still exists and the program isn't doing anything I normally don't do (move the mouse), it just does it for me.

That probably is still a strech but like someone else said, unless they knew I had this program there is almost no way of knowing whats going on so it's a lot safer. Sure they could fire me for it, but they could fire me for lots of things worse than this I'm sure. Being on the IT dept makes a big difference :)

O.K., with your script you are actively circumventing the IT policy. Why do you think you could get fired for changing the group policy and not for "disabling" it by running your script??

I guess, there is a reason for your policy....

Cheers

Kurt

<{POST_SNAPBACK}>

www.TomTheGeek.com - All the geeky stuff that gets me hot
Link to comment
Share on other sites

Mainly because I am only circumventing the IT policy on one computer at a time and not the entire domain. Also, this way I'm not breaking the rules, just sort of bending them. The GP still exists and the program isn't doing anything I normally don't do (move the mouse), it just does it for me.

That probably is still a strech but like someone else said, unless they knew I had this program there is almost no way of knowing whats going on so it's a lot safer. Sure they could fire me for it, but they could fire me for lots of things worse than this I'm sure. Being on the IT dept makes a big difference  :)

<{POST_SNAPBACK}>

here we go, i tweaked it a little to help avoid the whole firing thing... now there is a hotkey... when you run the script, it kills the screensaver, then idles around doing nothing until you hit the pause button at which point it restores the screensaver functionality...

$old = RegRead ( "HKEY_CURRENT_USER\Control Panel\Desktop\","SCRNSAVE.EXE" )
$KILL = RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop\","SCRNSAVE.EXE","REG_SZ","")
HotKeySet("{PAUSE}","ToggleSS")

while 1
    sleep(1000)
WEnd

Func ToggleSS()
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop\","SCRNSAVE.EXE","REG_SZ",$old)
    Exit
EndFunc
Link to comment
Share on other sites

I too wanted to toggle killsaver on and off. I added an a checked menu item to the traymenu and changed the tool tip to show current state of activation.

I tried using the reg but found that the screensaver would not restart after changing the key with regwrite. But if I merge it in, It worked. Any ideas?

I don't have either code here (home.) I'll try to upload it later.

-Steve

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