I have had a few questions on taking an image and making it the wallpaper for the desktop. This is a function that I have tried to tidy up so it can be put into anyones project. Here are the details:
You will need to set the tile and style when using the function. So [On Click] place this code
The function takes three parameters. The first two are for the orientation (ile and style respectively) of the image and the third is the image itself. Only pass .jpgs or .bmps to this function.
Centered = 0,0
Stretched = 0,2
Tiled = 1,0
NOTE: For the jpg conversion to work you need to use a program by Worm called JPG2BMP.EXE (attached below)
You will need to set the tile and style when using the function. So [On Click] place this code
Code:
SetWallpaper(0,2,image_name_or_variable)
Centered = 0,0
Stretched = 0,2
Tiled = 1,0
NOTE: For the jpg conversion to work you need to use a program by Worm called JPG2BMP.EXE (attached below)
Code:
function SetWallpaper(tile,style,img) local imagesplit = String.SplitPath(img) if imagesplit.Extension == ".jpg" then --runs a program created by Worm from the AMS Forum to convert .jpgs to .bmps File.Run(_SourceFolder .."\\JPG2BMP.EXE", img .. ";;" .. _WindowsFolder .. "\\ams5.bmp", "", SW_MINIMIZE, true); setreg = true; elseif imagesplit.Extension == ".bmp" then --copy the image to the windows folder File.Copy(img, _WindowsFolder .. "\\ams5.bmp", false, true, true, true, nil) setreg = true; else Dialog.Message("Error","The image you have selected is not supported."); setreg = false; end --sets the registry value for tile and stretch if setreg == true then Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "TileWallpaper", tile, REG_SZ); Registry.SetValue(HKEY_CURRENT_USER, "Control Panel\\Desktop", "WallpaperStyle", style, REG_SZ); DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SystemParametersInfoA", "20,0,\"" .. _WindowsFolder .. "\\ams5.bmp\",1", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL); end end
Comment