使用 PowerShell 腳本自動轉(zhuǎn)存聚焦壁紙
在 Windows 10 鎖屏界面上,聚焦壁紙是一種令人賞心悅目的體驗,但如何將其保存并設(shè)置為桌面壁紙呢?下面是一個利用 PowerShell 腳本實現(xiàn)自動下載和保存 Windows 10 聚焦壁紙的
在 Windows 10 鎖屏界面上,聚焦壁紙是一種令人賞心悅目的體驗,但如何將其保存并設(shè)置為桌面壁紙呢?下面是一個利用 PowerShell 腳本實現(xiàn)自動下載和保存 Windows 10 聚焦壁紙的方法。
創(chuàng)建 PowerShell 腳本
首先,我們需要創(chuàng)建一個 PowerShell 腳本來自動轉(zhuǎn)存聚焦壁紙。你可以使用記事本或任何代碼編輯器來新建一個文本文檔,并將以下內(nèi)容粘貼到其中,然后將其保存為 文件。
```powershell
將復制出來的緩存圖片保存在下面的文件夾
add-type -AssemblyName System.Drawing
New-Item "$($env:USERPROFILE)PicturesSpotlight" -ItemType directory -Force
New-Item "$($env:USERPROFILE)PicturesSpotlightCopyAssets" -ItemType directory -Force
New-Item "$($env:USERPROFILE)PicturesSpotlightHorizontal" -ItemType directory -Force
New-Item "$($env:USERPROFILE)PicturesSpotlightVertical" -ItemType directory -Force
路徑說明:保存位置在你的用戶名文件夾下的圖片文件夾 -> Spotlight -> Horizontal
foreach ($file in (Get-Item "$($env:LOCALAPPDATA)Packages_cw5n1h2txyewyLocalStateAssets*")) {
if ((Get-Item $file).length -lt 100kb) {
continue
}
Copy-Item $file.FullName "$($env:USERPROFILE)PicturesSpotlightCopyAssets$($).jpg";;
}
foreach ($newfile in (Get-Item "$($env:USERPROFILE)PicturesSpotlightCopyAssets*")) {
$image New-Object -comObject ;
$image.LoadFile($newfile.FullName);
if ($() -eq "1920") {
Move-Item $newfile.FullName "$($env:USERPROFILE)PicturesSpotlightHorizontal" -Force;
}
elseif ($() -eq "1080") {
Move-Item $newfile.FullName "$($env:USERPROFILE)PicturesSpotlightVertical" -Force;
}
}
```
執(zhí)行腳本保存圖片
保存完腳本后,你可以右鍵點擊該文件并選擇以 PowerShell 執(zhí)行,這樣腳本就會開始運行,并將聚焦壁紙自動保存到指定文件夾中。
設(shè)置聚焦圖片為桌面壁紙
執(zhí)行后,圖片實際保存路徑在 `C:Users你的用戶名PicturesSpotlightHorizontal`(不是 Windows 聚焦里)。至此,你已經(jīng)成功地將聚焦壁紙保存到本地,接下來只需手動將其中一張圖片設(shè)置為桌面壁紙即可。
這個 PowerShell 腳本簡化了保存和管理 Windows 10 聚焦壁紙的過程,讓你能夠更輕松地享受到精美的鎖屏壁紙。