I decided to try a different method of acheiving the goal. I used Win32::TieRegistry and Win32::GUITest to do it.

It still needs to have some file checks done to see if the input is a valid desktop wallpaper but I'll leave that as an exercise for someone else. I've had way too much fun today!

#!/usr/bin/perl use strict; use warnings; use Win32::TieRegistry; use Win32::GuiTest qw(FindWindowLike SetForegroundWindow PushButton); # Is Active Desktop enabled? Get the (REG_BINARY) value from the regis +try my $AD = $Registry->{'CUser\Software\Microsoft\Windows\CurrentVersion\ +Explorer\ShellState'}; $AD = unpack("x4 C", $AD ); # A BIG thanks to tye for this line! if ($AD == 19 or $AD == 99) { print "Active Desktop enabled.\n"; } elsif ($AD == 35 or $AD == 83) { print "Active Desktop disabled. Only bitmaps will work.\n"; } else { die "Unknown registry value"; } my $input; if (@ARGV == 0) { print "Enter the full name of the image to use: "; $input = <STDIN>; chomp($input); exit if ($input eq ""); } else { $input = $ARGV[0]; } print "\nUsing $input\n"; # add file tests to see if the input is a valid desktop wallpaper $Registry->{'CUser\Control Panel\Desktop\WallPaper'} = $input; system("control","desk.cpl") or die "oopsie"; my @windows = FindWindowLike(0, "^Display Properties"); # find all win +dows that match die "oopsie" unless @windows; my $hwnd = $windows[0]; # we'll just the first match SetForegroundWindow($hwnd); # Bring it the foreground PushButton("OK");

In reply to Re: IActiveDesktop::SetWallpaper from Perl? by Mr. Muskrat
in thread IActiveDesktop::SetWallpaper from Perl? by bbfu

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.