Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions stable/ChangeFullWindowsTheme.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$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) {
Set-ItemProperty -Path $registryPath -Name "AppsUseLightTheme" -Value $dwordValue -Type DWORD -Force
Set-ItemProperty -Path $registryPath -Name "SystemUsesLightTheme" -Value $dwordValue -Type DWORD -Force
}

# 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, IntPtr lParam, int fuFlags, int uTimeout, out IntPtr lpdwResult);
}
"@ -PassThru

$HWND_BROADCAST = [IntPtr]::Zero -bor 0xFFFF
$WM_SETTINGCHANGE = 0x1A
$SPI_SETCLIENTAREAANIMATION = 0x1043

$param = [System.Runtime.InteropServices.Marshal]::StringToHGlobalUni("ImmersiveColorSet")

$null = [Win32Utils]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, $param, 2, 5000, [ref]([IntPtr]::Zero))

[System.Runtime.InteropServices.Marshal]::FreeHGlobal($param)
Loading