简体   繁体   English

Python - 如何更改 windows 颜色主题

[英]Python - How to change windows color theme

My goal is to make a script to apply a certain boundle of settings all at once to my computer if something specific happens.我的目标是制作一个脚本,以便在发生特定情况时将一定范围的设置一次性应用到我的计算机上。 I am currently stuck, at how to change the windows color theme.我目前被困在如何更改 windows 颜色主题上。 I could figure out, how to change the theme from light to dark and reverse using this code:我可以弄清楚,如何使用以下代码将主题从浅色更改为深色并反转:

import subprocess

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

This code works, and i can use it to change from light to dark theme.此代码有效,我可以使用它从浅色主题更改为深色主题。 But there are also other settings in this settingsboundle:但是这个settingsboundle里还有其他的设置:

设置

i want to be able to change color accent, like in this image there is blue selected, to another color (for example red).我希望能够将颜色重音更改为另一种颜色(例如红色),例如在此图像中选择了蓝色。 I could not find any way to do this, nor how to universally change windows settings.我找不到任何方法来做到这一点,也找不到如何普遍更改 windows 设置。

Do you know any way of changing the windows color accent using python?您知道使用 python 更改 windows 颜色重音的任何方法吗?

Do you know of any way to change any windows setting, (such as the background, mouse cursor size, font, font size), perhaps is there even a module to it which can be used like in the following example:您是否知道更改任何windows 设置的任何方法(例如背景、鼠标 cursor 大小、字体、字体大小),也许甚至有一个模块可以使用,如下例所示:

import example

setting2 = windows.CURSOR_SIZE
setting2v = 15

example.change.setting(setting2, setting2v)
print("succesfully changed setting " + str(setting2) + " to value " + str(setting2v))

thank you:)谢谢你:)

(I am very sorry for bad english, i am still learning it) (我很抱歉英语不好,我还在学习它)

There's no Python module that makes it that easy to tweak Windows UI settings programmatically.没有 Python 模块可以轻松以编程方式调整 Windows UI 设置。 But you already have a working example of using reg.exe from Python.但是您已经有了一个使用 Python 中的 reg.exe 的工作示例。 You can use your working example as a basis for modifying other registry settings.您可以使用您的工作示例作为修改其他注册表设置的基础。 Now it's just a matter of locating the appropriate registry keys for the settings you want to change.现在只需为要更改的设置找到适当的注册表项即可。 You can do this using Google, example search query: registry key for personalize accent color .您可以使用 Google 执行此操作,例如搜索查询: registry key for personalize accent color

Here's a StackExchange post going over the keys for many Personalize settings:这是 StackExchange 帖子,其中介绍了许多 Personalize 设置的键:

https://superuser.com/a/1395560/54746 https://superuser.com/a/1395560/54746

Check this link How to change a certain windows setting using python?检查此链接如何使用 python 更改某个 windows 设置? It will show you how to run power shell commands using python.它将向您展示如何使用 python 运行电源 shell 命令。 From there you can apply any changes you want to your windows.从那里您可以对 windows 应用您想要的任何更改。

Good luck with your script!祝你的剧本好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM