diff --git a/stable/ChangeWindowsAppTheme.ps1 b/stable/ChangeWindowsAppTheme.ps1 index 719f979..0b2dc52 100644 --- a/stable/ChangeWindowsAppTheme.ps1 +++ b/stable/ChangeWindowsAppTheme.ps1 @@ -7,3 +7,22 @@ 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)) +} diff --git a/stable/ChangeWindowsSystemTheme.ps1 b/stable/ChangeWindowsSystemTheme.ps1 index 436db23..b15f0fe 100644 --- a/stable/ChangeWindowsSystemTheme.ps1 +++ b/stable/ChangeWindowsSystemTheme.ps1 @@ -7,3 +7,22 @@ if (Test-Path $registryPath) { New-ItemProperty -Path $registryPath -Name "SystemUsesLightTheme" -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)) +}