Instantly switch between dark and light mode for Windows

416 Views Asked by At

How to programmatically switch between dark and light mode for Windows. I used registry keys,

HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme
HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\SystemUsesLightTheme

But it does not execute the command directly like a toggle switch in the Color Settings\Personalize\Colors window.

Windows does not respond immediately to dark or light mode changes via registry keys

2

There are 2 best solutions below

4
Bender110001 On

You can use PowerShell scripts to achieve that. Example:

Enable Darkmode on Apps

New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force

Enable Lightmode on Apps

Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme
0
Natacha On

You can trigger an event in Windows tasks scheduler for every mode you want (light and dark, for example). There, in actions tab, set "start a program" with Powershell in program or script (type the following line):

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

And in "add optional args", insert this line (change AppsUseLightTheme for the var you wanna set and the value 0/1 depending on the time of day):

Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1

Also, to answer some of the comments in @Bender110001 answer, you got 2 vars for custom theme in Win11 (maybe 10 too):

  • AppsUseLightTheme for applications (Pycharm, browser pages, etc)
  • SystemUseLightTheme for system colors (as you can see in the Win customization manual config: taskbar, windows, OS style out of apps).