-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathChangeWindowsAppTheme.ps1
28 lines (23 loc) · 1.09 KB
/
ChangeWindowsAppTheme.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
$params = $Input | ConvertFrom-Json
$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"
$dwordValue = 1 - $(If ($params.themeMode -Eq 0) {$params.daySegment2} Else {$params.themeMode - 1})
if (Test-Path $registryPath)
{
New-ItemProperty -Path $registryPath -Name "AppsUseLightTheme" -Value $dwordValue -PropertyType DWORD -Force | Out-Null
}
if ([System.Environment]::OSVersion.Version.Build -ge 22000)
{
# Call Windows theme refresh
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Win32Utils {
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, out IntPtr lpdwResult);
}
"@ -PassThru
$HWND_BROADCAST = [IntPtr]0xFFFF
$WM_SETTINGCHANGE = 0x1A
$SMTO_ABORTIFHUNG = 0x2
[Win32Utils]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, 5000, [ref]([IntPtr]::Zero))
}