怎样自动把Windows聚焦设为壁纸

2025-10-22 01:52:44

1、新建一个文本文档,把这段代码复制到里面。

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\*";


2

怎样自动把Windows聚焦设为壁纸

怎样自动把Windows聚焦设为壁纸

2、把这个文件的后缀改为ps1,名字随便,这里就叫save-spotlight.ps1。

怎样自动把Windows聚焦设为壁纸

3、接下来修改文件打开方式,因为.ps1文件默认打开方式是记事本,我们把它改成Windows PowerShell。右键-打开方式,单击更多应用,勾上始终使用此程序打开.ps1文件,单击在这台电脑上查找其他应用,按照这个路径选择Windows PowerShell:C:\Windows\System32\WindowsPowerShell\v1.0\WindowsPowerShell。

怎样自动把Windows聚焦设为壁纸

怎样自动把Windows聚焦设为壁纸

怎样自动把Windows聚焦设为壁纸

4、桌面右键-个性化,选择幻灯片放映,在单击浏览,选择C:\Users\你的用户名\Pictures\Spotlight\Horizontal。再设置好多久换一次图片。如果没有这个文件夹,多运行几次刚才写的程序。

怎样自动把Windows聚焦设为壁纸

5、接下来要让它自动运行。我们创建一个刚才写的程序的快捷方式(一定要快捷方式)到这个文件夹C:\ProgramData\Microsoft\Windows\[开始]菜单\程序\启动。

怎样自动把Windows聚焦设为壁纸

6、开机出现这个窗口就OK了,它会自动保存Windows聚焦的图片并设为壁纸。

怎样自动把Windows聚焦设为壁纸

7、在power shell(管理员)中输入Set-ExecutionPolicy Unrestricted,在输入y,否则脚本无效

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢