用PS命令定时执行自动下载 Windows 10 聚焦壁纸

2024-10-31 16:25:13

1、脚本自动转存聚焦壁纸:(你也可以手动右键点击脚本选择Powershell执行)用记事本或代码编辑器新建文本文档然后粘贴以下内容,更改名称和后缀GetWallPaperFromSpotlight.ps1

2、# 将复制出来的缓存图片保存在下面的文件夹add-type -AssemblyName System.DrawingNew-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;#路径说明:保存位置在你的用户名文件夹下的图片文件夹--->Spotlight--->Horizontal# 将横竖图片分别复制到对应的两个文件夹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; }}

3、执行后图片实际保存路径在:C:\Users\你的用户名\Pictures\Spotlight\Horizontal (不是Windows聚焦里)

4、将自动转存的聚焦图片设置为壁纸:可选前面的脚本只是自动转存Windows 10聚焦的壁纸但不会设置桌面壁纸,设置的话还是要你手动进行设置的。

猜你喜欢