Set the color settings of Windows 10 in Python

Viewed 918

I want to set the colour theme of windows 10 (App-Mode) to dark mode or light mode. In C there is a DwmSetColorizationParameters method. But I can't find a similar in python. Is there a way to achieve this? (Just for clarifying it: I want the change windows settings)

1 Answers

To change the app color theme in Windows 10, you can edit the registry using these commands:

Dark Theme:

reg.exe add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v AppsUseLightTheme /t REG_DWORD /d 0 /f

Light Theme:

reg.exe add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v AppsUseLightTheme /t REG_DWORD /d 1 /f

Switching to dark mode in Python can be achieved using the subprocess package as follows:

import subprocess

command = ['reg.exe', 'add', 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize', 
           '/v', 'AppsUseLightTheme', '/t', 'REG_DWORD', '/d', '0', '/f']
subprocess.run(command)

The arguments for run must be passed in a list. To change to light mode the same code works but you just replace the command with the command to change to light mode.

I hope this answer helps.

Related