DonationCoder.com Software > Finished Programs
DONE: VBS set wallpaper from folder of backgrounds
(1/1)
Coniferous:
This is more of a frilly not important request,
But I would like a script that gets called on startup that changes my wallpaper to a randomly chosen image the lies in a folder contained in my documents.
(how’s that for a run-on sentence?).
Not sure how difficult this is, if it's harder then it seems let me know.
Winkie:
Not sure how difficult this is, if it's harder then it seems let me know.
-Coniferous (September 27, 2010, 09:02 AM)
--- End quote ---
It's not that difficult to script this in VBS, my limited VBS/VBA knowledge and some Googling was enough :-\.
But since you want an VBS-script it will remain very limited as far as I know. Because it only works with a folder with only bitmaps (*.bmp) with a size in pixels which exactly match your screen dimensions.
Anyway, here's the script (tested in WinXP):
--- Code: Visual Basic ---' WallpaperChanger.vbs - by Winkie - Last changed: 20100927Option Explicit Dim oShell, oScripting, aFilesArrayDim sWallpaperDir, sFolder, sFileDim i , iFiles, iSelection sFolder = "E:\Test\" ' Include quotes and last backslash Set oShell = CreateObject("WScript.Shell")Set oScripting = CreateObject("Scripting.FileSystemObject") Set sFolder = oScripting.GetFolder(sFolder) iFiles = CInt(sFolder.Files.Count) ReDim aFilesArray(0)For Each sFile in sFolder.Files ReDim Preserve aFilesArray(UBound(aFilesArray) + 1) aFilesArray(UBound(aFilesArray)) = sFile.ShortPathNext i = 1RandomizeiSelection = Int((UBound(aFilesArray) - i + 1) * Rnd + i) oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", aFilesArray(iSelection)oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, False
If it doesn't necessarily have to be an VBS-script, I'm sure an AutoHotkey-script can solve the limitations.
HTH,
Greetings Winkie
iskander71:
Wouaw, personnaly I am a newbeet so bravo !!
I want to learn but I don' t know where begin, with wich language, etc...and with wich 'editor' write all this coding, like yours here !!!!
Year I know, but I hope I will learn !!
Navigation
[0] Message Index
Go to full version