我的Windows 10笔记本电脑在扩展显示模式下连接到两台显示器。我只想将第二个显示器的墙纸设置为特定的图像。手动操作方式是导航:桌面右键单击-->个性化-->选择图片-->右键单击并设置为监视器2
有没有什么方法可以通过脚本(bat/powershell)实现自动化?
我能够获得下面的代码片段来工作,但是它将墙纸设置为两个显示器
function Set-Wallpaper($MyWallpaper){
$code = @'
using System.Runtime.InteropServices;
namespace Win32{
public class Wallpaper{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
public static void SetWallpaper(string thePath){
SystemParametersInfo(20,0,thePath,3);
}
}
}
'@
add-type $code
[Win32.Wallpaper]::SetWallpaper($MyWallpaper)
}
Set-WallPaper("C:\Wallpapers\nature.jpg")谢谢
发布于 2021-11-17 05:16:18
https://stackoverflow.com/questions/69838321
复制相似问题