#!/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 registry 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 = ; 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 windows that match die "oopsie" unless @windows; my $hwnd = $windows[0]; # we'll just the first match SetForegroundWindow($hwnd); # Bring it the foreground PushButton("OK");