I like Crash's ideas on this and will likely play with that a little. I was going to give just VB a shot. Hey, I am not a programmer type.
Based on your earlier post and reference to a Batch File to change wallpaper automatically I came up with a simple script written in VBScript simply because a .bat file isnâ€™t my forte and a .vbs file works for me. The script is a modified version of a script from Microsoft. Personally I like using scripts for all sorts of things. Before we worry about the script itself we should focus on the wallpaper settings Windows XP uses.
Since wallpaper is a user function and since any machine can have several users each liking different wallpaper the wallpaper settings are in the registry under HKEY_CURRENT_USER\Desktop\Wallpaper which really makes sense. If you navigate the registry to HKEY_CURRENT_USER\Desktop and look in the Right Pane you will see wallpaper as well as the path to the wallpaper Windows is currently using. The default for the standard wallpaper that comes with Windows XP is C:\Windows\Web\Wallpaper\somedamnpaper.bmp on my XP machine. However, wallpaper can be anywhere as long as the registry can point to it and it is where the registry points.
So here is what I did to simplify things. I took 6 pictures and named them Wallpaper1, Wallpaper2, â€¦ Wallpaper6. Notice my very complex naming conventions. I saved the images as .bmp (Bitmap) files to the folder C:\Windows\Web\Wallpaper along with the existing wallpaper in there. I could have placed them anywhere as long as the code in the script pointed to them. I could have saved them as .jpg and it would still work or I could have just used existing images in the folder in my script. I am sure you get the idea and if not just ask.
Something else you will notice are a few other wallpaper related things. TileWallpaper and WallpaperStyle are in there with REG_SZ values also. TileWallpaper value = 0 centers the image on the screen and 1 tiles it across the screen (depends on the actual image size). WallpaperStyle = 0 will just center the image and = 2 will Stretch to Fit the image. All of that could be added to the code for a specific image selected at random but I didnâ€™t bother with those settings.
The code itself just runs and randomly selects 1 of 6. The code can easily be modified changing the intHighNumber and adding more Case Statements. I quit at 6. Looking at the code I am sure you will see what is going on and get the idea.
So what to do? Copy and paste the code into Note Pad and name the file something like Wallpaper Changer.vbs the important thing here is the .vbs extension or when you save the file you will have saved it as a .txt file and a plain text file wonâ€™t do anything. Save the file to somewhere like the root of your C:\ drive. Double clicking the file will run it but we want it to run automatically.
Next we have a small problem to overcome. I used the XP task scheduler and scheduled the task to run at Logon. Just make sure that you set the task scheduler to run correctly and to run the file at logon for yourself. The script will not change the wallpaper in real time or on the fly. However each time the user logs off the next logon should have new wallpaper. Screw with the scheduler and edit the code for your needs and system. Just make sure you get the code correct as the registry is very funny about upper & lower case for example. Also I would be remiss if I didnâ€™t tell you to backup the registry before doing or clicking anything. There are other ways to do this in VBScript but this one works.
'Basic script to change the wallpaper in Windows XP
'Define the constant Name & set a value to it.
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
'Randomly select 1 of 6 Wallpapers using 2 variables as high and low.
intLowNumber = 1
intHighNumber = 6
intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
'We have a number between 1 and 6. We use select case to assign the RND #
'to a wallpaper.
Select Case intNumber
strValue = "C:\Windows\Web\Wallpaper\Wallpaper1.bmp"
strValue = "C:\Windows\Web\Wallpaper\Wallpaper2.bmp"
strValue = "C:\Windows\Web\Wallpaper\Wallpaper3.bmp"
strValue = "C:\Windows\Web\Wallpaper\Wallpaper4.bmp"
strValue = "C:\Windows\Web\Wallpaper\Wallpaper5.bmp"
strValue = "C:\Windows\Web\Wallpaper\Wallpaper6.bmp"
'We change the registry key that points to the wallpaper Windows will use.
strKeyPath = "Control Panel\Desktop"
ValueName = "Wallpaper"
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue
You can mess with that and see what it does. Keep in mind this is quick and dirty.