我创建了这个VBScript来随机化我的墙纸。 它还将子文件夹用于顺序图像。 它从指定的父文件夹中的文件或文件夹之一中随机选择。 如果选择文件,则等待10分钟以进行更改。 如果选择文件夹,它将每5秒按顺序浏览图片。
要使用它,请将代码复制并保存到.vbs文件,如果希望其自动启动,请将其放在启动文件夹中。
Option Explicit
Dim WshShell, oFolder, intNumber, strValue, i, oFile, strFolder, intFolders, intFiles, serialIndex, sleepTime, serialFolder
strFolder = "C:\Documents and Settings\username\My Documents\My Pictures\Wallpapers\"
Set WshShell = WScript.CreateObject("Wscript.Shell")
Set oFolder = WScript.CreateObject("Scripting.FileSystemObject").GetFolder(strFolder)
serialIndex = 0
Do While True
Do While True
If serialIndex > 0 Then
serialIndex = serialIndex + 1
If serialIndex > serialFolder.Files.Count Then serialIndex = 0
End If
If serialIndex > 0 Then
i = 0
For Each oFile In serialFolder.Files
i = i + 1
If i = serialIndex Then Exit For
Next
Else
intFiles = oFolder.Files.Count
intFolders = oFolder.Subfolders.Count
Randomize
intNumber = Int((intFiles + intFolders) * Rnd) + 1
If intNumber > intFiles Then
sleepTime = 5000
serialIndex = 1
i = intFiles
For Each serialFolder In oFolder.Subfolders
i = i + 1
If i = intNumber Then Exit For
Next
i = 0
For Each oFile In serialFolder.Files
i = i + 1
If i = serialIndex Then Exit For
Next
Else
sleepTime = 600000
i = 0
For Each oFile In oFolder.Files
i = i + 1
If i = intNumber Then Exit For
Next
End If
End If
If oFile.Path <> strValue Then
strValue = oFile.Path
Exit Do
End If
Loop
Set oFile = Nothing
WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", strValue
WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False
WScript.Sleep sleepTime
Loop
Set WshShell = Nothing
Set oFolder = Nothing
From: https://bytes.com/topic/windows/insights/905645-random-wallpaper-script