TomTheGeek Posted June 30, 2005 Share Posted June 30, 2005 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!! expandcollapse popupOpt("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() EndFuncKillSaver.zip www.TomTheGeek.com - All the geeky stuff that gets me hot Link to comment Share on other sites More sharing options...
jftuga Posted June 30, 2005 Share Posted June 30, 2005 Can you access the registry to determine how many minutes of inactivity (wait time) before the SS starts? If so, you can make the default $sleepTime equal to that time minus one minute. What do you think? -John Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
blindwig Posted June 30, 2005 Share Posted June 30, 2005 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? My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
jftuga Posted June 30, 2005 Share Posted June 30, 2005 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 Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
blindwig Posted June 30, 2005 Share Posted June 30, 2005 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? My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
jftuga Posted July 1, 2005 Share Posted July 1, 2005 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 Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
seandisanti Posted July 13, 2005 Share Posted July 13, 2005 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 More sharing options...
seandisanti Posted July 13, 2005 Share Posted July 13, 2005 (edited) 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 THENMSGBOX(0,"SUCCESS","SCREENSAVER KILLED")ELSEMSGBOX(0,"FAIL","SCREENSAVER NOT KILLED")ENDIF Edited July 13, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
Nova Posted July 13, 2005 Share Posted July 13, 2005 Wait a second your company will not let you change display settings but they allow you edit the registry? Link to comment Share on other sites More sharing options...
seandisanti Posted July 13, 2005 Share Posted July 13, 2005 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 More sharing options...
seandisanti Posted July 13, 2005 Share Posted July 13, 2005 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 More sharing options...
Doug Posted July 13, 2005 Share Posted July 13, 2005 This utility could be useful for online games that time you out and close your connection if you're idle too long...it would be especially gratifying if the game took minutes to restart. Link to comment Share on other sites More sharing options...
ryeguy Posted July 13, 2005 Share Posted July 13, 2005 There's no such thing as an online game that doesn't have the option to turn off the idle quit thing. Link to comment Share on other sites More sharing options...
seandisanti Posted July 14, 2005 Share Posted July 14, 2005 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 More sharing options...
Insolence Posted July 14, 2005 Share Posted July 14, 2005 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 More sharing options...
TomTheGeek Posted July 27, 2005 Author Share Posted July 27, 2005 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 More sharing options...
/dev/null Posted July 27, 2005 Share Posted July 27, 2005 (edited) 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....CheersKurt Edited July 27, 2005 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 More sharing options...
TomTheGeek Posted July 27, 2005 Author Share Posted July 27, 2005 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....CheersKurt<{POST_SNAPBACK}> www.TomTheGeek.com - All the geeky stuff that gets me hot Link to comment Share on other sites More sharing options...
seandisanti Posted July 27, 2005 Share Posted July 27, 2005 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 More sharing options...
eltorro Posted July 30, 2005 Share Posted July 30, 2005 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 Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now