Toogle Light/Dark Mode Programmatically in Windows 11
Asked Answered
G

1

7

I would like to toggle light / dark mode on Windows 11 programmatically.

Existing solutions are unsatisfactory:

  1. use the Registry values "AppsUseLightTheme" and "SystemUsesLightTheme". This worked perfectly in Windows 10. However, in Windows 11 the change is not applied in all places. For example, when switching to dark mode, Explorer windows are still light. And the clock text in the right corner of the Taskbar is still black, so now the clock cannot be read anymore.

  2. select a different Theme programmatically - however, this changes my Desktop background. I'd really just like to change the dark/light mode and keep everything else the same.

What's the best way to accomplish this?

Galicia answered 13/1, 2023 at 9:13 Comment(1)
Microsoft has been really bad at exposing these things to 3rd-party applications the last few years, doubt there is anything official. Maybe an undocumented function in uxtheme?Heliograph
C
1

this is a little old topic but I'd like to share my (partial but ok I guess) solution:

create a couple of scheduled tasks:

Light theme

Program:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe    

Arguments:
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 1 -Type Dword -Force; New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1 -Type Dword -Force; New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent -Name AccentColorMenu -Value 0 -Type Dword -Force; New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent -Name AccentColorMenu -Value 0xff1d3f58 -Type Dword -Force

Dark Theme

Program:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe    

Arguments:
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 0 -Type Dword -Force; New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force; New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent -Name AccentColorMenu -Value 0 -Type Dword -Force; New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent -Name AccentColorMenu -Value 0xff1d3f58 -Type Dword -Force

Especially the following:

New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent -Name AccentColorMenu -Value 0 -Type Dword -Force; New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent -Name AccentColorMenu -Value 0xff1d3f58 -Type Dword -Force

allowed me to force the change of the taskbar from light to dark but apparently with a little quirk: the second display taskbar does not switch to the actual color but stays on the previous one, who knows why, on the primary display it works fine so if you have one display you should have no problem.

If anyone can help fixing this it would be nice

Cathedral answered 21/9 at 11:54 Comment(1)
Apparently after some time the secondary display changes the color of the taskbar to the light/dark theme as well...Cathedral

© 2022 - 2024 — McMap. All rights reserved.