Post Reply

Forums -> UltraMon™ -> Automatically changing one wallpaper in Windows 10
Matth   2017-06-01 22:27
I have the following PowerShell script that changes my wallpaper every 10 minutes with the latest satellite image. How can I adjust that script so that it only adjusts the wallpaper on one monitor, but not on the other?

Here's the script:

## Download a satellite picture and set it as the new wallpaper

Add-Type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace Wallpaper
{
public enum Style : int
{
Fit, Tile, Center, Stretch, NoChange
}
public class Setter {
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni);
public static void SetWallpaper ( string path, Wallpaper.Style style ) {
SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
switch( style )
{
case Style.Stretch :
key.SetValue(@"WallpaperStyle", "2") ;
key.SetValue(@"TileWallpaper", "0") ;
break;
case Style.Center :
key.SetValue(@"WallpaperStyle", "1") ;
key.SetValue(@"TileWallpaper", "0") ;
break;
case Style.Tile :
key.SetValue(@"WallpaperStyle", "1") ;
key.SetValue(@"TileWallpaper", "1") ;
break;
case Style.NoChange :
break;
}
key.Close();
}
}
}
"@

Invoke-WebRequest -Uri "http://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/full_disk_ahi_true_color.jpg" -OutFile "C:\Users\Matth\Pictures\temp\spacebg.jpg"
[Wallpaper.Setter]::SetWallpaper('C:\Users\Matth\Pictures\temp\spacebg.jpg', 0)
Christian Studer   2017-06-02 15:18
To set this up, create an UltraMon wallpaper profile with the satellite image assigned to one monitor, then after updating the image run the ReloadWallpaper2 script to recreate the wallpaper with the updated satellite image.

Christian Studer - www.realtimesoft.com
Matth   2017-06-04 07:17
Thanks, that works
Forums -> UltraMon™ -> Automatically changing one wallpaper in Windows 10

Post Reply