« 'Don't Make Me Think' Workshop is coming to Portland | Firefox tweak: Spell check any text field »

August 15, 2007

Automatically stretch Webshots backgrounds

I recently upgraded from an old 19" CRT monitor to a 19" widescreen LCD monitor. While the widescreen is great for watching movies, my Webshots desktop backgrounds don't fit the new aspect ratio very well.

By changing the background properties from center to stretch I could force Windows to resize the background to fix the screen. Although this slightly distorts the picture, I found that I preferred it to the black bars normally on the left and right sides of the picture. The only problem is that every time Webshots changed the background picture, it would change the background setting back from stretch to center.

I finally found a way to automatically "stretch" the background pictures after Webshots changed them. I found a very useful program called AutoIt. According to their web site, "AutoIt is a freeware Windows automation language. It can be used to script most simple Windows-based tasks."

I wrote a little script that changes the wallpaper mode to stretch. Then I used the compiler that comes with AutoIt to compile the script into an executable .exe file. Then I created a scheduled task that runs the executable every minute.

So now when Webshots changes the background, it will automatically get stretched within a minute when the scheduled script runs.


;
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x/NT
; Author: Richard Davies
;
; Script Function:
; Changes wallpaper mode to 'stretch'.
;

Dim $pos
$pos = RegRead("HKU\S-1-5-21-1645522239-2139871995-725345543-1003\Control Panel\Desktop", "WallpaperStyle")

If $pos <> 2 Then
; Load display properties
Run("control desk.cpl display,,2")

; Wait for it to load and make it transparent
WinWaitActive("Display Properties")
WinSetTrans("Display Properties", "", 0)

; Set wallpaper mode to stretch
Send("!p")
Send("s")

; Close window
Send("{enter}")
EndIf

The registry string in the second line is your SID. You can use the PsGetSid utility to find your SID.

Update: See Automatically stretch Webshots backgrounds redux for an improved (and Vista compatible) method of accomplishing this task.

Posted at 7:18 PM in Computers