如何以编程方式将 Powershell 背景颜色设置为 RGB 值 [英] How to set Powershell background color programmatically to RGB Value

查看:28
本文介绍了如何以编程方式将 Powershell 背景颜色设置为 RGB 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前从 Console Colors 中选择的 16 种颜色对我来说不是正确的选择.我想使用这些颜色更深的变体作为背景.

The current selection of 16 colors from Console Colors is not the right choice for me. I would like to use much darker variants of these for the background.

我绝对可以使用 UI 设置这些并在那里更改 RGB 值.

I could definitely set these using the UI and changing the RGB value there.

例如,我可以选择深蓝色,然后在 RGB 部分中为蓝色选择 65(默认为 128).有人可以告诉我如何以编程方式执行此操作.

For example, I could choose Darkblue and select 65 for Blue in the RGB section(128 is the default). Could some one tell me how to do this programmatically.

类似:

(Get-Host).UI.RawUI.BackgroundColor=DarkBlue

但有额外的选择.

推荐答案

Lee Holmes 的这篇旧文章解释了如何将颜色更改为所需的任何值.您必须更改注册表 - http://www.leeholmes.com/blog/2008/06/01/powershells-noble-blue/

This old post by Lee Holmes explains how you can go about changing the color to any value you want. You have to change the registry - http://www.leeholmes.com/blog/2008/06/01/powershells-noble-blue/

Push-Location 
Set-Location HKCU:Console 
New-Item ".\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe" 
Set-Location ".\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe"

New-ItemProperty . ColorTable00 -type DWORD -value 0×00562401 
New-ItemProperty . ColorTable07 -type DWORD -value 0x00f0edee 
New-ItemProperty . FaceName -type STRING -value "Lucida Console" 
New-ItemProperty . FontFamily -type DWORD -value 0×00000036 
New-ItemProperty . FontSize -type DWORD -value 0x000c0000 
New-ItemProperty . FontWeight -type DWORD -value 0×00000190 
New-ItemProperty . HistoryNoDup -type DWORD -value 0×00000000 
New-ItemProperty . QuickEdit -type DWORD -value 0×00000001 
New-ItemProperty . ScreenBufferSize -type DWORD -value 0x0bb80078 
New-ItemProperty . WindowSize -type DWORD -value 0×00320078 
Pop-Location

这篇关于如何以编程方式将 Powershell 背景颜色设置为 RGB 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆