Skip to content

Commit

Permalink
Merge pull request #54 from KrakenByte27/patch-1
Browse files Browse the repository at this point in the history
Added auto-refresh for ChangeWindows<System>/<App>Theme.ps1
  • Loading branch information
t1m0thyj authored Mar 6, 2025
2 parents 89e79de + 73bdd4b commit 82bad90
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions stable/ChangeWindowsAppTheme.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
19 changes: 19 additions & 0 deletions stable/ChangeWindowsSystemTheme.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit 82bad90

Please sign in to comment.