白日梦观察 - pictures
type: channel
link: https://blog.angustar.com/tag/pictures/
items: 保存 Windows 10 锁屏壁纸——Windows 聚焦

保存 Windows 10 锁屏壁纸——Windows 聚焦
type: item
date: 2021-04-04T22:41:00+08:00
description: 将以下代码保存为.ps1后缀的文件，或点击此处下载Save-Spotlight.zip并解压。 add-type -AssemblyName System.Drawing New-Item "$($env:USERPROFILE)\Pictures\Spotlight" -ItemType directory -Force; New-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets" -ItemType directory -Force; New-Item "$($env:USERPROFILE)\Pictures\Spotlight\Horizontal" -ItemType directory -Force; New-Item "$($env:USERPROFILE)\Pictures\Spotlight\Vertical" -ItemType directory -Force; foreach($file in (Get-Item "$($env:LOCALAPPDATA)\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\*")) { if ((Get-Item $file).length -lt 100kb) { continue } Copy-Item $file.FullName "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\$($file.Name).jpg"; } foreach($newfile in (Get-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\*")) { $image = New-Object -comObject WIA.ImageFile; $image.LoadFile($newfile.FullName); if($image.Width.ToString() -eq "1920"){ Move-Item $newfile.FullName "$($env:USERPROFILE)\Pictures\Spotlight\Horizontal" -Force; } elseif($image.Width.ToString() -eq "1080"){ Move-Item $newfile.FullName "$($env:USERPROFILE)\Pictures\Spotlight\Vertical" -Force; } } Remove-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\*"; 运行后脚本会自动将图片保存至「此电脑 > 图片 > Spotlight」内，如图所示，非常方便~