Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: IActiveDesktop::SetWallpaper from Perl?

by Mr. Muskrat (Canon)
on Oct 19, 2002 at 18:22 UTC ( [id://206543]=note: print w/replies, xml ) Need Help??


in reply to IActiveDesktop::SetWallpaper from Perl?

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");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://206543]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2025-07-18 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.