Useful Windows Screensavers - Including Windows 10
Useful Windows Screensavers - Including Windows 10
Written by Mike James   
Thursday, 24 September 2015
Article Index
Useful Windows Screensavers - Including Windows 10
A Form Based Screensaver

The screensaver is an example of a vestigial technology - it no longer serves its original purpose. However, this doesn't mean it isn't useful in other ways and it is supported on all versions of Windows including Windows 10.

The screensaver is no longer needed as a way of protecting displays from damage due to “burn in” but it is a very useful way of automatically running a program.

If the user hasn’t pressed a key or moved the mouse for a set time then the configured screensaver kicks in. This provides us with a way of running a program when the machine is idle and a way of presenting the user with some information on their return.

Notice that it is usual for a screensaver to unload itself when the user presses a key or moves the mouse – but this isn’t mandatory. What the screensaver does after it has been loaded is entirely up to you and when you realise that a screensaver will run even before you have logged on to the machine and you can see that the scope for clever stuff is even greater.

So perhaps screensavers aren’t a complete waste of time – in fact they might well be just the opposite, i.e. a way of using otherwise waste computing time…

Saving screens

So how do you create a screensaver application?

It turns out to be surprisingly easy but if you look it up in the documentation you might not think so.

There have been various attempts over the years to create a screensaver “framework”, which have generally only made something very simple seem much more difficult.

Getting started

It’s always helpful to examine the simplest example of a project type so that you can really see how things work. Although screensavers seem complicated they are just standard .EXE files with their file names changed to end in .SCR. They also live in either the Windows/System or Windows/System32 directory.

If you select a screensaver then when the machine has been idle for the specified amount of time it is loaded and run as a standard EXE file would be.

Well there is a little more to it than this but this is a good starting point for a program. The only additional thing we need to take into account when writing a first screensaver is that the screensaver loader passes the screensaver a command line parameter to tell it what to do.





Start in screensaver mode


Show configuration dialog box with whatever window is currently active as the parent


Show a preview of your screensaver


Show the configuration dialog box with no parent window.


The good news is that you really only need to support the /s option to create the simplest possible screensaver.

Start a new C# Console project called ScreenSaver1.

This provides you with the initial code you need, i.e. a main function that is run when the application starts.

The main function receives the command line parameters as a single string, which is called “args” for "arguments" by default:

static void Main(string[] args)

If there are any command line parameters the args string will have a length greater than zero:

if (args.Length > 0)

Given the simple nature of the possible parameters we can convert them into a standard form of two characters in lower case:

string arg = args[0].ToLower().
                      Trim().Substring(0, 2);

The result can now be used to decide what to do. You could use nested if statements but a switch is so much neater and easier to follow:

switch (arg)
  case "/c":
  case "/s":
  case "/p":

The final else clause belongs to the initial if statement and is executed if there are no command line parameters when we simply show the screensaver.

At some point in the future we are going to have to supply functions to deal with all three possibilities but for the moment all we need is the ShowScreenSaver function.

In principle this could do anything you want it to but the normal action of a screensaver is to load graphics to fill the screen.

The simplest way of doing this in many languages is to load a form and customise it to fill the screen.

For this simple example we just load a form and leave the customisation to later. Add a form called Screen to the project. Use the command Project,Add Windows Form.




There is no need to do anything to it and add, just after the main function just defined:

static void ShowScreenSaver()
 Application.Run(new Screen());

This uses the Application object to run, on a new thread, a new instance of the form.

This not only loads the form but start its “message pump” running which makes it responsive. After this the thread running the main function can terminate and the screen form will remain active until the user closes it.

Finally to make this work we need to add a reference to System.Windows.Forms if there isn't already one in the project. Use the Project,Add Reference command. You also need to add:

using System.Windows.Forms;

to the start of the file continuing the main function. 

Now we are ready to try the screensaver, but there is one small complication.

At the moment the project is designated as a console project and as such it displays a command window and refuses to display Windows forms.

In fact we really want a Windows project and have created a console project just to get the system to generate the main function and other related code.

To make the project work all that is necessary is to use the Project,Properties menu item and in the dialog box that opens change the Output type from Console Application to Windows Application and set the Startup object to be the ScreenSaver1.Program to ensure that it is the main function that starts running first.




Now we can run the program to check that the screen form does appear.


To make the screensaver work under Windows 10 you also need to change the Target Framework to 4.

Next we need to install the screensaver. To do this you have to navigate to the project’s debug directory, find ScreenSaver1.exe and rename it to ScreenSaver1.scr.

Next you can either copy it to the Windows/System32 directory or you can right click on the desktop, select the Screen Saver tab and finally select ScreenSaver1 in the drop down list.

Copying the file to the System32 directory makes the installation permanent in the sense that it is available in the Screen Saver tab dropdown list.

While you are testing the screensaver a quicker way is to right click on the ScreenSaver1.scr file and select Install from the drop-down menu. This starts the Windows Screen Saver Dialog Box which you can use to select your screensaver.

This also isn’t a permanent installation in the sense that if you select another screensaver at a later time your screensaver isn’t re-presented in the list of possible choices.

You can click the preview button to see what the screensaver actually does. If you want to check that it really does start after a period of inactivity change the “Wait” time to 1 minute. It is worth noticing that all that happens when your “screensaver” starts is that the screen form appears. Nothing else happens to the form unless you close it, using the close box.

You can see that the screensaver mechanism is a good way of getting almost any program started during a period of inactivity and it doesn’t have to stop running the instant the user returns.








Last Updated ( Tuesday, 06 October 2015 )

RSS feed of all content
I Programmer - full contents
Copyright © 2015 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.