Home > Blockchain >  How can I use Python to navigate Windows 10 UI to change a specific setting?
How can I use Python to navigate Windows 10 UI to change a specific setting?

Time:09-19

What I want to do is create a script that allows me to toggle Windows 10 clear and dark mode without having to manually go to settings every time, which requires 4 or 5 steps.

I've been looking at the os module but haven't found a method that would let me navigate the task bar or the notifications center to access the settings from there, nor have I found a way to change that setting from a folder using basic Windows Explorer navigation.

The process would be to open the settings, navigate to the colors setting and toggle the color. Or do it by altering some file on the Windows folder for example, that would change that setting without opening the settings window.

CodePudding user response:

I don't think there is a python library that can tweak Windows UI settings (e.g: colors, mode, ..). However, to enable the dark mode in your Windows 10, you can use the python built-in module enter image description here

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize]
    "AppsUseLightTheme"=dword:00000000

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize]
    "SystemUsesLightTheme"=dword:00000000

With Python, try this :

import subprocess

dark_app_mode = ['reg.exe', 'add', 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize', 
           '/v', 'AppsUseLightTheme', '/t', 'REG_DWORD', '/d', '0', '/f']
dark_windows_mode = ['reg.exe', 'add', 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize', 
           '/v', 'SystemUsesLightTheme', '/t', 'REG_DWORD', '/d', '0', '/f']

subprocess.run(dark_app_mode)
subprocess.run(dark_windows_mode)

Or this :

from subprocess import Popen

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

commands = [dark_app_mode, dark_windows_mode]

processes = [Popen(cmd, shell=True) for cmd in commands]

RESULT :

This will set a FULL dark mode in your Windows 10 (or 11) :

enter image description here

  • Related