forked from StartAutomating/PowerShellAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet-DalleImageAsWallpaper.ps1
45 lines (36 loc) · 1.33 KB
/
Set-DalleImageAsWallpaper.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function Set-DalleImageAsWallpaper {
<#
.SYNOPSIS
Sets a DALL-E image as the desktop background
.EXAMPLE
Set-DalleImageAsBackground "A picture of a cat"
.EXAMPLE
Set-DalleImageAsBackground "A picture of a cat" -Size 512
#>
param(
[Parameter(Mandatory)]
$Description,
[ValidateSet('256', '512', '1024')]
$Size = 256
)
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Params
{
[DllImport("User32.dll",CharSet=CharSet.Unicode)]
public static extern int SystemParametersInfo (Int32 uAction,
Int32 uParam,
String lpvParam,
Int32 fuWinIni);
}
"@
$SPI_SETDESKWALLPAPER = 0x0014
$UpdateIniFile = 0x01
$SendChangeEvent = 0x02
$fWinIni = $UpdateIniFile -bor $SendChangeEvent
$Image = Get-DalleImage $Description -Size $Size
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name wallpaperstyle -Value 0 # centered
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name tilewallpaper -Value 0 # centered
$null = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni)
}