Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

NoSleep.exe - Prevents Screensaver and PC Locking

Updated: 29 Jul 2010 | 7 comments
Mike.Langford's picture
+8 8 Votes
Login to vote

I wrote a little utility that runs in your system tray and prevents your computer from locking or going into screensaver mode as it normally would when idle and while it is not really Symantec related, I have found it very useful and I thought I would share it.

Why would you want to prevent this you ask?

Well, I work on two PCs and group policy sets our screensaver and locking timeout. Quite often I would be working on PC1 for a few minutes and then PC2 would lock, so when I want to go back to PC2, I would unlock it. Then while I am on PC2, PC1 would lock. I found myself unlocking my PCs several times a day and it started to get annoying. I am all in favor of security and still lock my PCs when I leave my desk, but this little utility keeps them active while I am sitting here.

How does it work?

It is very simple. All it does is move your mouse one pixel to the left, and then one pixel to the right every 30 seconds. This tiny bit of movement is invisible to the user, but is enough to make Windows think that someone is using the PC.

While running, you will see this icon in your system tray:

imagebrowser image

If you want to exit the utility, simply right click it and click "Exit"

Comments

KSchroeder's picture
23
Jul
2009
1 Vote +1
Login to vote

I've thought about making

I've thought about making something that does exactly what you're doing here, but never knew enough Windows programming to do it.  Nice work!

Thanks,
Kyle
Symantec Trusted Advisor

For Forum threads, please click "Mark as Solution" if answered.
For all content, please give a thumbs up if you agree with or support the post.

ktran's picture
28
Jul
2009
1 Vote +1
Login to vote

Nice utility

This is a nice utility, what language do you use to create this?

Mike.Langford's picture
30
Jul
2009
3 Votes +3
Login to vote

Autoit

It is an easy little scriping language called AutoIt.  Similar to VB Script, but it has GUI functionallity, and compiles to an EXE which is kind of handy.

Only about 30 lines of code total, most of which is setting up he tray icon.  The actual mouse moving code is only 6 lines.  Basically tells it, until someone closes the app, idle around for 30 seconds, then get the position of the mouse and move it right and left one pixel.  Then it loops and idles around fr 30 more seconds.

While 1
    Sleep(30000)
    $CurPos = MouseGetPos ( )
    MouseMove ( $CurPos[0] + 1, $CurPos[1] )
    MouseMove ( $CurPos[0] - 1, $CurPos[1] )
WEnd

Check out www.autoitscript.com if you are interested.  I do most my stuff in C#, but sometimes,  a simple script is all you need.

Cheers

Orlando.Stevenson's picture
18
Sep
2009
1 Vote +1
Login to vote

Nice Utility - Enhancing it?

Looks like this approach should work well with Win 7 .  Would you mind sharing your 30 lines of full source code behind this.. perhaps include in your Winzip?     In our case, would be good if such a facility self-exited after so much time  - especially for conference rooms - and wouldn't take too much to enhance further.

Nice job!

    

Mike.Langford's picture
07
Oct
2009
1 Vote +1
Login to vote

Sure, here is the entire

Sure, here is the entire source code.  I will update the zip so it contains the uncompiled version as well.

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)

$AboutItem = TrayCreateItem("About")
TrayItemSetOnEvent(-1,"ReadList")
TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ReadList")

Func ReadList()
 $SelectedItem = TrayItemGetText(@TRAY_ID)
 If $SelectedItem="Exit" Then
  Exit
 ElseIf $SelectedItem="About" Then
  Call("About")
 EndIf
EndFunc

Func About()
 MsgBox(064,"No Sleep Utility","Prevents your computer from automatically locking or going to screen saver as it normally would." & @CRLF & "Copyright Mike Langford ©2009")
EndFunc

While 1
 Sleep(30000)
 $CurPos = MouseGetPos ( )
 MouseMove ( $CurPos[0] + 1, $CurPos[1] )
 MouseMove ( $CurPos[0] - 1, $CurPos[1] )
WEnd
Mike.Langford's picture
07
Oct
2009
1 Vote +1
Login to vote

Source Code Included

FYI,
The ZIP now contains the Au3 file, which is just text based source code that Autoit can compile to an EXE.

Sid Markolov's picture
16
Oct
2009
0 Votes 0
Login to vote

Very Helpful!

Thanks for the code.  Looks pretty straight forward!