Hi, I got inspired on this code to add something that would also change the wallpaper from a random list in a directory:)

You should copy this code between the last constant definition and the next comment (#if you wish to use...)

## ***************** the SHIFTER ******************************* ## CHANGE THE DESKTOP BACKGROUND IMAGE... # dirIni = path to the directory where I have all the pictures to sor +t and choose one... my ($dirIni)='C:\Program files\Pictures\ImageCatcher'; # dirDesti= where I must record the new picture to write on it my ($dirDesti)='C:\Perl\guiones\images\Wallpaper1.bmp'; # tipos = valid image extensions of my pictures my ($tipos)= '\.jpg|\.gif|\.bmp|\.png|.\tif'; ##sort a list of valid images and return one with its complete path #sub nvaImagen { my (@ims); chdir($dirIni); opendir(DIR,$dirIni) or die("Cant open directory $dirIni $!"); ## grep filters & creates an array of valid pictures @ims = grep { $_ = "$dirIni/$_" if (/$tipos/ && -f "$dirIni/$_") ; $_ if (/$tipos/ && -f "$_"); } readdir(DIR); ##read every file closedir(DIR); ## the lotery... my ($ete)= int rand($#ims + .9999) if (@ims); my ($ima)= $ims[$ete] if ($ete && @ims); print "$ete - $ima\n"; ## checking the result ## reading the new image... my ($imobj, $er)=(Image::Magick->new,''); $er = $imobj->read($ima) if ($ima); die ("Error reading $ima [Img-Mgk] says: $er $!") if ($er); ## standarize an image size with IM $imobj->Resize(width=>800, height=>600, blur=>1); ## write the new image over the same old one $imobj->Write($dirDesti); } ## **********************/ the SHIFTER **************************
Before using this new code, you should try the previous code, and see if it works ok. Then add this new part and call it when you start your system. Works nice, but might need some adjustments...

You should change the directories and of course, the image name that is being displayed. This last one might not need to be changed if you have tryied the previous original code.

There is also a regex filter list of image file extensions that you might need to add/modify. It doesn't matter the extension since Image::Magick does the conversion to .BMP.

Please, read some info about how you might need to fine-tune Image::Magick on Windows (it is not that easy, but it works if you follow the recipy).

Thank you Koosemose for your inspiration!


In reply to adding some code... win-Wallpaper shifter! by chanio
in thread WallFortune by Koosemose

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.