MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically.
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 = 0 Dim $FindFile = FileFindFirstFile($favDir & '*.bmp') While 1 FileFindNextFile($FindFile) If @error Then ExitLoop $cCounter = $cCounter + 1 WEnd FileClose($FindFile) $FindFile = FileFindFirstFile($favDir & '*.bmp') Dim $RandomNum = Random(1, $cCounter, 1) Dim $curFile For $i = 1 To $RandomNum $curFile = FileFindNextFile($FindFile) If $RandomNum = $i Then ChangeDesktopWallpaper($favDir & $curFile) ExitLoop EndIf Next FileClose($FindFile) Exit Func 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" Logic Local $SPI_SETDESKWALLPAPER = 20 Local $SPIF_UPDATEINIFILE = 1 Local $SPIF_SENDCHANGE = 2 Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop" ;Don't tile - just center RegWrite($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 0 EndFunc;==>_ChangeDestopWallpaper Change_Desktop.au3