IdleLock – a utility to lock your PC after X minutes of idle time

IdleLockIconIf you want your Windows PC to lock (i.e. require you to enter your password to use it) after a period of user inactivity, you can go to the screen saver setting and check “On resume, display logon screen”. But what if you want the screensaver to be activated after e.g. 10 minutes, but you don’t want the PC to lock until after 20 minutes? In Windows XP, you could resort to the ScreenSaverGracePeriod registry hack. However, in Windows 7 and later, the PC will be locked no later than 60 seconds after the screensaver kicks in, no matter what ScreenSaverGracePeriod value you have specified. To remedy this flaw, I whipped up IdleLock, a small utility that locks your PC after a selectable time of user inactivity.

Using IdleLock

When running, you control IdleLock by clicking it’s icon in the system tray. NB: In order for the “Only lock if screensaver is active” option to work, you must set a wait period for your screensaver that is shorter than the time you have set for the display to turn off. In other words, the screensaver must start before the display powers off.

Download

Download the program here. You don’t have to install it, just copy it to wherever you like (e.g. the Startup folder) and run it from there.

Resource use

IdleLock is very lean. It uses about 1MB of memory on Windows 8.1 and CPU use isn’t even detectable.

The problem with screensaver detection

Not very long ago, it was all too common to see the screensaver start or the monitor power off while you were watching video. Fortunately, this is mostly a phenomena of bygone days. Needless to say, it would be even more annoying to see the PC lock and prompt you for a password, just when Clint Eastwood and Lee Van Cleef are about to exchange lead (or whatever pivotal scene you may be watching). The seemingly easy way of avoiding this, is to have IdleLock check whether the screensaver is running and only lock the PC if it is. Unfortunately, Windows will report that the screensaver if not running when the power settings have caused the monitor to be powered off. I have searched for ways to detect the power state of the monitor, but according to this thread on Stackoverflow, there is no reliable way to do that.

The kludge I resorted to, was to detect when the screensaver starts and consider it running until new user input is detected. This will, of course, only work if the screensaver is set to start before the display is powered off. Otherwise, the screensaver will never be started.

Source code

Available on GitHub (C++).

  1. No comments yet.

  1. No trackbacks yet.