Skip to content

Commit 82bad90

Browse files
authored
Merge pull request #54 from KrakenByte27/patch-1
Added auto-refresh for ChangeWindows<System>/<App>Theme.ps1
2 parents 89e79de + 73bdd4b commit 82bad90

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

stable/ChangeWindowsAppTheme.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,22 @@ if (Test-Path $registryPath)
77
{
88
New-ItemProperty -Path $registryPath -Name "AppsUseLightTheme" -Value $dwordValue -PropertyType DWORD -Force | Out-Null
99
}
10+
11+
if ([System.Environment]::OSVersion.Version.Build -ge 22000)
12+
{
13+
# Call Windows theme refresh
14+
Add-Type -TypeDefinition @"
15+
using System;
16+
using System.Runtime.InteropServices;
17+
18+
public class Win32Utils {
19+
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
20+
public static extern int SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, out IntPtr lpdwResult);
21+
}
22+
"@ -PassThru
23+
24+
$HWND_BROADCAST = [IntPtr]0xFFFF
25+
$WM_SETTINGCHANGE = 0x1A
26+
$SMTO_ABORTIFHUNG = 0x2
27+
[Win32Utils]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, 5000, [ref]([IntPtr]::Zero))
28+
}

stable/ChangeWindowsSystemTheme.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,22 @@ if (Test-Path $registryPath)
77
{
88
New-ItemProperty -Path $registryPath -Name "SystemUsesLightTheme" -Value $dwordValue -PropertyType DWORD -Force | Out-Null
99
}
10+
11+
if ([System.Environment]::OSVersion.Version.Build -ge 22000)
12+
{
13+
# Call Windows theme refresh
14+
Add-Type -TypeDefinition @"
15+
using System;
16+
using System.Runtime.InteropServices;
17+
18+
public class Win32Utils {
19+
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
20+
public static extern int SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, out IntPtr lpdwResult);
21+
}
22+
"@ -PassThru
23+
24+
$HWND_BROADCAST = [IntPtr]0xFFFF
25+
$WM_SETTINGCHANGE = 0x1A
26+
$SMTO_ABORTIFHUNG = 0x2
27+
[Win32Utils]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, 5000, [ref]([IntPtr]::Zero))
28+
}

0 commit comments

Comments
 (0)