Video Screencast Help
Search Video Help Close Back
to help

NoSleep.exe - Prevents Screensaver and PC Locking

Created: 22 Jul 2009 | Updated: 29 Jul 2010 | 13 comments
Mike.Langford's picture
0 0 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 13 CommentsJump to latest comment

KSchroeder's picture

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.

+1
Login to vote
ktran's picture

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

+1
Login to vote
Mike.Langford's picture

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

+3
Login to vote
Orlando.Stevenson's picture

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!

    

+1
Login to vote
Mike.Langford's picture

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
+1
Login to vote
Mike.Langford's picture

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

+1
Login to vote
Sid Markolov's picture

Thanks for the code.  Looks pretty straight forward!

0
Login to vote
Tornadokat's picture

This causes my cursor to end up 2 pixels to the left every time.

0
Login to vote
heliwasp's picture

Actually the source code has a bug.

The mouse position has been stored in a local variable, so it should be moved back to that position. Instead, as a second move it is being set to initial position -1 (1 Pixel to the left):

 

MouseMove ( $CurPos[0] - 1, $CurPos[1] )

 

Replace that line with the following, and the mouse position shouldn't drift any longer:

 

MouseMove ( $CurPos[0], $CurPos[1] )

 

 

0
Login to vote
PatchRowcester's picture

You sir, are a genius! 

 

Thank you so much! 

0
Login to vote
Dilippatel's picture

This is genuine utility can we use in corporate?

0
Login to vote
k3nnyg's picture

Hmmmm.. not bad. This won't work for everything though. If you just want the computer not to lock this will work in most(not all) circumstances(Win7, Win8, UAC. Many more things to consider these days). Attached is a utility I wrote. Its in C# and uses pInvoke to get the exact timeouts for each profile and then adjusts the reset values accordingly. This will not move your mouse or type phantom characters like some do. This will also make you appear active on OCS, gchat, Lync, Outlook,etc. This works on ANY Windows version under any type ofdomain or individual security policy(GPOs). This utility is more meant to make you appear that you are actually at your terminal working even if you step away. Really it was written as a POC. The file ImWorkin.exe is in the root of the zip if you just want the pre-copmpiled exed. Otherwise the whole C# project is there for you too.

 

I dont condone slacking off but at times you may find a need for this utility. Use it wisely and dont abuse it too much because ultimatley it doesnt matter how your computer look if you arent actually producing your deliverables to your managment!

 

Enjoy

 

Source included in the zip.....Requires .NET 4 or above.

AttachmentSize
ImWorkin.zip 240.14 KB
0
Login to vote
bonjour madame's picture

FYI : Panda, Quick Heal and Clam AV detect a virus in NoSleep.exe: http://virusscan.jotti.org/en/scanresult/76c4d987b...

Nothing found in ImWorkin.exe

 

 

0
Login to vote