aboutblank Posted June 17, 2006 Posted June 17, 2006 (edited) Hey guys. I LOVE THE FORUM!I couldn't find anywhere else to put this, so I decided to post it here. This AutoIt script will grab a random .bmp from a given directory and set it as the desktop. Change $favDir to your own directory from which to grab. Irfanview can be used to convert .jpgs to .bmps. Windows actually only can load .bmps to the desktop and usually does the conversion on-the-fly when you set a .jpg to the desktop. Hope it's appreciated Personally, I have a startup item linking to the script so it changes when Windows starts.PLEASE NOTE: I have used stolen code in this script. I don't know where it came from. Some of it is my work, some of it is not.Dim $favDir = 'C:\Downloads\Wallpapers\favorites\'Dim $cCounter = 0Dim $FindFile = FileFindFirstFile($favDir & '*.bmp')While 1 FileFindNextFile($FindFile) If @error Then ExitLoop $cCounter = $cCounter + 1WEndFileClose($FindFile)$FindFile = FileFindFirstFile($favDir & '*.bmp')Dim $RandomNum = Random(1, $cCounter, 1)Dim $curFileFor $i = 1 To $RandomNum $curFile = FileFindNextFile($FindFile) If $RandomNum = $i Then ChangeDesktopWallpaper($favDir & $curFile) ExitLoop EndIfNextFileClose($FindFile)ExitFunc ChangeDesktopWallpaper($bmp);===============================================================================; Usage: _ChangeDesktopWallPaper(@WindowsDir & '\' & 'zapotec.bmp'); Parameter(s): $bmp - Full Path to BitMap File (*.bmp); Requirement(s): None.; Return Value(s): On Success - Returns 0; On Failure - -1;===============================================================================If Not FileExists($bmp) Then Return -1;The $SPI* values could be defined elsewhere via #include - if you conflict,; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" LogicLocal $SPI_SETDESKWALLPAPER = 20Local $SPIF_UPDATEINIFILE = 1Local $SPIF_SENDCHANGE = 2Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop";Don't tile - just centerRegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)RegWrite($REG_DESKTOP, "Wallpaper", "REG_SZ", $bmp)DllCall("user32.dll", "int", "SystemParametersInfo", _"int", $SPI_SETDESKWALLPAPER, _"int", 0, _"str", $bmp, _"int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))Return 0EndFunc;==>_ChangeDestopWallpaperChange_Desktop.au3 Edited June 17, 2006 by aboutblank
SmOke_N Posted June 20, 2006 Posted June 20, 2006 PLEASE NOTE: I have used stolen code in this script. I don't know where it came from. Some of it is my work, some of it is not. B) Maybe Here?
--=ddSHADOW=-- Posted June 24, 2006 Posted June 24, 2006 PLEASE NOTE: I have used stolen code in this script. I don't know where it came from. Some of it is my work, some of it is not. B) Maybe Here? man this is some nice program u got there EnCodeIt
SmOke_N Posted July 17, 2006 Posted July 17, 2006 PLEASE NOTE: I have used stolen code in this script. I don't know where it came from. Some of it is my work, some of it is not. B) Maybe Here? man this is some nice program u got there EnCodeIt Thanks
Ryuho Posted September 4, 2008 Posted September 4, 2008 Sorry to bring up such an old thread, but I need help getting this piece of code to work.My OS is XP PS3 with the latest AutoIt compiler and SciTEI run the code, and the wallpaper doesn't change, so I right click on my desktop and go to Properties. I noticed that the preview image on the properties window now has changed to one of the specified wallpaper, I click some other wallpaper and reselect the previously selected wallpaper (which is one of the wallaper that the autoit script selected) and I hit Ok, the wallpaper changed to one of the correct wallpaper.So I think the wallpaper just needs to get refreshed.. but I don't know how I would do that.. Any Help? I just want a script/program/command to be able to select a random wallpaper from a directory and set it as the wallpaper when I want to.
MadBoy Posted September 4, 2008 Posted September 4, 2008 Sorry to bring up such an old thread, but I need help getting this piece of code to work.My OS is XP PS3 with the latest AutoIt compiler and SciTEI run the code, and the wallpaper doesn't change, so I right click on my desktop and go to Properties. I noticed that the preview image on the properties window now has changed to one of the specified wallpaper, I click some other wallpaper and reselect the previously selected wallpaper (which is one of the wallaper that the autoit script selected) and I hit Ok, the wallpaper changed to one of the correct wallpaper.So I think the wallpaper just needs to get refreshed.. but I don't know how I would do that.. Any Help? I just want a script/program/command to be able to select a random wallpaper from a directory and set it as the wallpaper when I want to.Kill the explorer.exe, and rerun it. Maybe this will fix it?
Ryuho Posted September 4, 2008 Posted September 4, 2008 It didn't work, and besides that would suck if I had to restart my shell and file browser each time I wanted to change my wallpaper...
jozuman Posted September 12, 2008 Posted September 12, 2008 hey... this is freakin awesome. but how do you get it to be stretched, not centered. (i'm new here.)
Ryuho Posted September 19, 2008 Posted September 19, 2008 I'm still having trouble using this peice of script.. does anyone have an alternative autoit script that I can try out?Or can anyone tell me how to refresh the wallpaper without shutting down explorer?
anandchakru2 Posted January 29, 2009 Posted January 29, 2009 (edited) hey... this is freakin awesome. but how do you get it to be stretched, not centered. (i'm new here.)Change RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)toRegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 2) Edited January 29, 2009 by anandchakru2
Geej Posted January 29, 2009 Posted January 29, 2009 There are 3rd party tools that can do the job, such as Automatic Wallpaper Changer
Geej Posted September 29, 2009 Posted September 29, 2009 ChangeDesktopWallpaper.au3I have attempt to modify the script to make it work with all images type (.png, .bmp, jpg etc). Since it need to be converted to bmp, I use IrfanView main executable to do this task. Hence for the script to work, it requires you to put i_view32.exe in either the same folder as the script or C:\Windows. (I prefer C:\Windows)Image location is C:\WINDOWS\Web\WallpaperI have included the modified script (as in the above) for you to edit as well as the compiled script (as in below) so that non-autoit user can also use it.Tested in XP only. Enjoy ChangeDesktopWallpaper.exe
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now