![]() |
|
Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
IActiveDesktop::SetWallpaper from Perl?by bbfu (Curate) |
on Oct 18, 2002 at 18:18 UTC ( [id://206394]=perlquestion: print w/replies, xml ) | Need Help?? |
bbfu has asked for the wisdom of the Perl Monks concerning the following question: First, my question. :) Is there any way to use IActiveDesktop::SetWallpaper from Perl? I've tried Win32::API but, probably because it's an object method, I can't seem to import it directly. I can import CoCreateInstance but I can't really figure out how to use it, nor would I know how to call the method on the resulting object. Now, some background. :) I am currently using, via Win32::API, SystemParametersInfo to set the wallpaper. It works, but it will only accept Windows bitmap files. I have been converting the files (which I store as JPEG) as needed, using ImageMagick, but I ran into a problem. There are a handful of files that, when converted to bitmap with ImageMagick's convert program, don't work as wallpapers in Windows XP. When I open the bitmaps in any other program, they display fine but if I try to set them as the wallpaper (either using SystemParametersInfo, or by manually setting the desktop wallpaper via the Control Panel), it won't set. It acts like it takes it, but the background doesn't change, and as you open / close / move windows, it redraws parts of the desktop in the background color (ie, it doesn't redraw the whole desktop in the background color at once, as you would expect). The strange thing is that I can copy these exact same bitmaps over to a Windows 2000 Pro machine, and they work fine as the wallpaper. And if I manually set the wallpaper to the original JPEG file for these images, it works fine in XP as well. It seems to be something between ImageMagick's convert and Windows XP reading the resulting bitmaps. I can't see anything about either the source JPEG or the resulting bitmap that seems any different from any of the others, that work fine. It is very consistant, though; it's always the same files that cause the problem. (If anyone wants a copy of one of the problem files, reply here, or /msg me.) So, anyway, I wanted to use IActiveDesktop::SetWallpaper, to take advantage of the built-in conversion routines. I don't know if it's feasable but, if so, I would greatly appreciate any suggestions. I'd also appreciate any recommendations on another good command-line driven conversion program that I could try. For what it's worth, here's the code I'm currently using to set the wallpaper, along with my poor attempt at using CoCreateInstance:
And here's the snippet where I call convert.exe:
Note that the same problem occurs if I do everything manually (ie, I manually run convert.exe on the file, and manually set the wallpaper to the resulting bitmap). So the problem really doesn't seem to be in my code, unless I'm really missing something. *shrug* :) bbfu
Back to
Seekers of Perl Wisdom
|
|