Category: Win32
Author/Contact Info fockjef@iit.edu
Description: This is a little script I wrote to grab a random cartoon from redmeat and set my wallpaper to it. The script runs everytime I log on. It could easily be modified to grab images from somewhere else.
#!perl

use LWP::Simple;
use Image::Magick;
use Win32::API;

print "Retrieving list of pictures....";
$base_url = "http://redmeat.com/redmeat/";
$redmeat = get($base_url."/meatlocker/index.html");
print "DONE!\n";

print "Selecting a random picture.....";
while( $redmeat =~ s/<li>(.*)// ){push( @Toons, $1);}
$pic = $Toons[int(rand(scalar @Toons))];
print "DONE!\n";

print "Downloading selected picture...";
$pic =~ s/.*"(.*)".*/$1/;
$pic =~ s/\.\.\//$base_url/;
$pic =~ s/\.html/-1.gif/;
getstore( $pic, "redmeat.gif");
print "DONE!\n";

print "Converting picture to bitmap...";
$pic = new Image::Magick;
$pic->Read("redmeat.gif");
$pic->Write("redmeat.bmp");
@cmd = ( "del", "redmeat.gif");
system(@cmd);
print "DONE!\n";

print "Setting picture as wallpaper...";
$SetWallpaper = new Win32::API( "user32", "SystemParametersInfo", ["N"
+, "N", "P", "N"], "N");
$SetWallpaper->Call( 20, 0, "redmeat.bmp", 3);
print "DONE!\n";