我有 Windows 10 笔记本电脑,我非常喜欢 Windows 偶尔自动更改的所有锁定屏幕壁纸。是否可以同时用相同的壁纸更改我的桌面背景?
答案1
从这里:https://www.thewindowsclub.com/use-windows-spotlight-desktop-wallpaper-slideshow
将以下内容保存为 Powershell 脚本:
$files = gci $Env:LocalAppData\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets | where Length -gt 1kb
if ($files) {
$shell = New-Object -ComObject Shell.Application
#destination for pictures (if doesn't exist, will be created)
$folder = "$Env:USERPROFILE\OneDrive\Pictures\Wallpaper\Spotlight"
if (!(Test-Path $folder)) { mkdir $folder }
$files | % {
$_ | Copy-Item -Destination $folder\$_.jpg
Get-Item $folder\$_.jpg
} | % {
$namespace = $shell.namespace($folder)
$item = $namespace.ParseName($_.Name)
$size = $namespace.GetDetailsOf($item, 31)
if ($size -match '(\d+) x (\d+)') {
$width = [int]($Matches[1])
$height = [int]($Matches[2])
}
if (!$size -or $width -lt 1920 -or $height -lt 500) {
Remove-Item $_
}
}
}
如果愿意,请修改该行$folder = "$Env:USERPROFILE\OneDrive\Pictures\Wallpaper\Spotlight"
以将文件放置在所需的位置。
将以下内容保存为 .xml 文件:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2017-11-23T15:57:26.1901555</Date>
<Author>SP4\skeene</Author>
<Description>Copies files larger than 1kb from "LocalAppData\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets" to "USERPROFILE\OneDrive\Pictures\Wallpaper\Spotlight\", omiting any files with a width less than 1920 or height less than 500 pixels.</Description>
<URI>\Shawn Keene\Copy Spotlight Pictures</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2017-11-23T23:55:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-744251132-1553713446-1048557590-1001</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<Duration>PT5M</Duration>
<WaitTimeout>PT1H</WaitTimeout>
<StopOnIdleEnd>false</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>true</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"</Command>
<Arguments>-ExecutionPolicy Bypass -file "C:\Path\To\PowerShel\Script\savespotlight.ps1"</Arguments>
</Exec>
</Actions>
</Task>
如果您修改了 PowerShell 脚本,则需要在 XML 文件中做出相应的更改。此外,您还需要更改参数行以指向您的 Powershell 脚本文件位置:<Arguments>-ExecutionPolicy Bypass -file "C:\Path\To\PowerShel\Script\savespotlight.ps1"</Arguments>
打开任务计划程序并将此 XML 导入为计划任务。根据需要调整设置。设置触发器以每天运行此脚本。
现在打开设置>个性化并将背景设置为幻灯片,并选择您指定为幻灯片图像的源文件夹的文件夹。