System.SetWallpaper: why does it copy my pictures?

So I'm using drag and drop to get the file path to my pictures. I store the file path in object.persiststorage. Then, system.setwallpaper calls on object.persiststorage and
changes the wallpaper to whatever is in object.persistorage. (I hope you're still with me here). Now, when I go to My Pictures there is a copy of every picture that has been set as my wallpaper. Is this normal or am I doing something wrong?

Any help or suggestions are greatly appreciated. Thank you.
4,400 views 6 replies
Reply #1 Top
Someone on the WCdx forums said they were having this problem as well. He also said that it was probably either DX or Windows that insists on using bmp. I tried a bitmap picture and it did not make a copy.

Does anyone here have any suggestions?

Reply #2 Top
rename everything to have .bmp instead of .jpg, .png or whatever they are.
Reply #3 Top
You mean I have to go through ALL of my pictures; changing them to bitmaps?

(Note, that I do not put the actual file name in the script. I use drag and drop to get the filename.)
Reply #4 Top
You're right - it WILL create a copy of the file because Windows must use a Bitmap image as the wallpaper. When setting a JPEG or png image as a wallpaper normally, Windows converts it internally and stores it as a Bitmap format temporarily.

What I have done to compensate for this in my wallpaper changer (Porthole: http://www.deviantart.com/view/34946883/) was to set up a check to see if there is a copy first in the original format and second in the bitmap format. If it comes back true then it deletes the bitmap copy before moving on the next image.
Reply #5 Top
Hi, Sranshaft.

I downloaded your object. I see the icon in my system tray but I can't seem to figure out how it works.

If I'm understanding correctly, your script checks to see if WINDOWS has already made a copy internally, and if it has, it then it deletes the copy DX makes? ( I'm a scripting amateur so this gets a little confusing sometimes.)

You wouldn't be interested in posting that code would you?    I should probably note that I plan on releasing this widget I'm making. So if you don't want me to use your code I'm fine with that.

Reply #6 Top
I'll take that as a 'no'.  

Alright, Garibaldi99 over at the WCdxforums has been great at trying to help me out. He gave me this code :

Dim fso, sourcefile
Set fso = CreateObject ("Scripting.FileSystemObject")
Set windowspath = fso.GetSpecialFolder(0)
Set sourcefile = fso.GetFile(Object.PersistStorage("picpath"))
sourcefile.Copy windowspath & "\wallpaperfile.jpg",True
system.setwallpaper windowspath & "\wallpaperfile.jpg",1


He said that it would copy the file to the windows directory before setting it as a wallpaper, and overwrite it each time.

I tested it and now it does not change the wallpaper. I'm sure it just needs a little tweaking somewhere in there but if I knew how to do that I wouldn't be here asking around.

This is my full script (with the additional code):

Sub Object_OnScriptEnter
d= weekday(date)
call Checkday
End Sub

Sub Object_OnDropFiles(files)
Dim path

path= Split(files, "|")
newpath= LBound(path)
newpath2= path(newpath)
object.PersistStorage("picpath") = newpath2
object.ToolTipText= (object.PersistStorage("picpath"))

call Checkday
End Sub

Function Checkday
d= weekday(date)
Select Case d
Case 1
Dim fso, sourcefile
Set fso = CreateObject ("Scripting.FileSystemObject")
Set windowspath = fso.GetSpecialFolder(0)
Set sourcefile = fso.GetFile(Object.PersistStorage("picpath"))
sourcefile.Copy windowspath & "\wallpaperfile.jpg",True
system.setwallpaper windowspath & "\wallpaperfile.jpg",3
End Select
End Function

-----------------

So, does anyone here have any ideas or suggestions? Here's my post at the WCdxForums:https://forums.wincustomize.com/index.aspx?ForumID=37&AID=122752#960933