While password-locked screensavers are a security necessity at many businesses, in most homes the screensaver's only real purpose is to...well...save the screen. It can become a little bit of an annoyance to have to tap the keyboard or move the mouse whenever you walk up to the computer to see what's going on. It's especially annoying if you have scans running or some other activity that you just want to monitor over a long period of time. The screensaver will kick in, and you have to tap the keyboard or move the mouse to remove it.

Wouldn't it be cool if your computer acted a little bit more like one of those advanced computers you read about in science fiction novels, where you can simply walk up to it and it can sense that you are there and respond accordingly? I mean, these days almost every computer comes with a webcam of some sort, often embedded right above the monitor, so the potential for smarter, more automated computers is there.

There may be some newer computer systems that already do this, but for the most part people are still stuck with tapping the keyboard to disable the screen saver. I started thinking about this the other day and decided to try to put together a combination of applications and scripts that would accomplish this simple automation task (yes, these are the sorts of things automation engineers do for fun).

The Motion-Detection Screensaver Solution

What I came up with was an application-script combination that would constantly monitor the webcam for motion, and then instantly run a script that would remove the screensaver. Deciding on the webcam software was easy. I was tempted to use the Active Webcam software that I previously wrote about, but then I realized that YawCam, which Mark covered before, is much simpler and more effective for this sort of task.

Once you install and run YawCam (and give them a nice donation for offering us this free software), you'll see the following screen over the webcam video.

disable screen saver

Click on "Window" and then choose Motion detection from the dropdown list. On the next screen, you'll see a page where the motion detection software logs each time a motion event takes place (when the detection is activated). Click on the "Actions" tab to set up the file that you'll have YawCam run whenever motion is detected.

automate screen saver

On this screen, you'll see a "Settings..." button next to Run.exe. Select the checkbox next to "Run.exe" and then click on the settings button.

automate screen saver

Click on the Activate check box for flood control (you don't want the script launching 50 times a second), and put some delay (I put 10 seconds, but you can use up to 60 or more). The next step would be to click on the browse button and choose your script file that you want to run. Alas, you don't have one yet. Don't worry, I've got you covered.

You'll notice that the default filter looks for .bat or .exe files, but you can also choose a Windows Script file (.wsf). For this article, I hunted for a whole list of ways to kill the screensaver via script. I searched for programs that already exist, or batch job methods that disable the screen saver. In each of those cases the screensaver stays disabled - not good. So then I turned to methods to send keyboard keys or mouse clicks to Windows - and sure enough, that was the solution.

After digging around Microsoft help files, I found the SendKeys code that simulates pressing the "Enter" button on the keyboard.

The following is the script.

<package>

<job>

<script language="VBScript">

set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.SendKeys("{ENTER}")

</script>

</job>

</package>

Save this script to a .wsf file and point the Action event in YawCam to that file. Now, every time there's motion in the webcam, it'll kick off your script, which simulates pressing the keyboard enter key - which will disable the screen saver.

If you find that your script isn't getting launched or the motion detection doesn't seem to be working (or it's too sensitive), make sure to check out the "Settings" tab in YawCam. Make sure that the tolerance is high enough so it's not too sensitive, and make sure the sensitivity is high enough so that it picks up when you sit down in front of the computer.

disable screen saver

As with most automated solutions, this one isn't perfect yet because you have to turn it off when you actually want to use the computer or it'll keep sending the "Enter" key whenever there's motion. I'm sure there are other creative ways you can probably perfect this automated screensaver trick. The solution above will work best for situations where you have something running for hours (like a virus scan) and you want to just walk up to the screen and have it automatically show you what's going on, but then the screensaver will reactivate after you walk away.

Did you install this automated screensaver setup? How well did it work for you? Did you find a way to perfect the system even more? Share your insights in the comments section below.

Image Credit: Vivek Chugh