« YikeSite is the perfect lighweight CMS
Don't break the web? »
February 4, 2008
Automatically stretch Webshots backgrounds redux
As I mentioned in a previous entry, a while back I created a little script to automatically stretch my Webshots wallpaper images to fill my widescreen monitor. However, after upgrading to Windows Vista this script didn't work correctly since it is basically just a macro that simulates the keystrokes a user would type to open up Display Properties and change the wallpaper mode to stretch.
I tried to update this macro with the Vista-specific keystrokes, but for some unknown reason, the program seemed to work fine when run manually, but when I tried to run it as a scheduled task, it would hang. It may have had something to do with Vista's more restrictive security policies. Anyway, try as I might, I was unable to get it to work reliably as a scheduled task, which totally defeated the purpose of the script.
So I did some research on other ways to accomplish my task and stumbled upon the "correct" way to change the wallpaper mode programmatically. It basically requires that you update the registry key containing the wallpaper mode setting and then make a special call to the user32.dll to instruct Windows to reread the registry key and update the settings as specified.
After some tinkering, I was able to get this to work. The best news is that now the script is even shorter and faster! I've included the AutoIt script below:
; AutoIt Version: 3.0
; Language: English
; Platform: Windows Vista
; Author: Richard Davies (Richard@richarddavies.us)
; Script Function:
; Changes wallpaper mode to 'stretch'.
Dim $wp = RegRead("HKCU\Control Panel\Desktop", "WallPaper")
RegWrite("HKCU\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", 2)
DllCall("user32.dll", "none", "SystemParametersInfo", "int", 20, "int", 0, "str", $wp, "int", 0x02)
Posted at 7:41 AM in Computers
This is a great idea and would like to use your script, but how do I get the script to run automatically? Do I have to manually run the script every day at each reboot?
Posted on September 18, 2008 at 8:58 AM
What I did was create a scheduled task in Windows that runs this script in the background every minute or two.
Posted on September 18, 2008 at 9:06 AM
Hi, I think we are talking about doing thesame thing here. My background works with webshots rather strange. I can open the personization program in Vista and then as soon as i click on background the webshot photo expands to full screen. (the way its supposed to look) But the next time a new picture comes up, its smaller and centered on the screen again. So webshots is set to fit to screen and windows is set to stretch but it doesn't seem to do that..
Maybe I'm not able to recreate some of your steps properly. I simply copied your script into a text file and then used AutoIt. I added the txt file to the first section of AutoIt and had it output an exe file. I ran the file but nothing happened. Am i missing something. You said that you had to make a registry change and then have the script just go back and read it and it looks like you have the registry change in the script, so the user doesn't really have to make the change themselves. Is that right?
Posted on February 5, 2009 at 5:35 AM
Yes, the script does all of the registry changes so you shouldn't have to do anything other than run the script. The script should change whatever wallpaper you currently are using to the "stretch" setting.
What do you mean you added the script to the "first section" of AutoIt? For debugging purposes, you can run the script inside AutoIt without compiling it to an .exe. Does anything happen when you try this?
Posted on February 5, 2009 at 7:45 AM
Thanks for this article. It didn't apply to my situation but I think I can solve my problem using SystemParametersInfo.
Posted on July 1, 2009 at 4:56 AM
Thanks for the clever and awesome solution! It's amazing how such a small detail can be so irritating! You've totally made my day.
Posted on January 27, 2010 at 7:22 AM
I know this is an old topic, but I still use my old Webshots.
Instead of going to all that trouble with scheduling...its better to correct Webshots...
Get a binary editor, like UltraEdit...and load up the file C:\Windows\Webshots.scr and then search for the ASCII entry of "WallpaperStyle" and change it to "TileWallpaper" and null out the last character with 00...you'll also notice there already is a "TileWallpaper" entry there...we've just made it set that registry entry twice...and hence it wont change the "WallpaperStyle" entry on you anymore...
Now that is solved, you just have to open up regedit.exe and browse to...
And change it from 0 to 2.
But please note, the long number will probably be different on your system. There are only 6 "WallpaperStyle" entries in the registry, and all 5 of them should be at 2 already. So you find the one that ain't and your sorted!
Have a good one!
Posted on February 4, 2011 at 12:51 PM
Canada Lee, thank you for posting your suggestion! That looks like an very good approach. I'll have to try that sometime when I get a minute.
Posted on February 4, 2011 at 12:59 PM
Thanks again, Canada Lee. I followed your instructions and it worked perfectly! No more scheduled task--now I have native wallpaper stretching. I love it!
Posted on February 14, 2011 at 8:19 PM
Post a comment