简体   繁体   English

Windows API将输出颜色输出到Powershell / cmd.exe中的stdout

[英]Windows API colored output to stdout in Powershell/cmd.exe

任何人都知道在哪里可以找到描述如何使用API​​和/或stdout在Windows CLI界面上输出颜色的参考?

The Win32 console API has a function, SetConsoleTextAttribute , that can be used to set the text foreground and background colours. Win32 控制台API有一个函数SetConsoleTextAttribute ,可用于设置文本前景色和背景色。 Sample code is here . 示例代码在这里

At least there is the color command: 至少有颜色命令:

color bg fg

where: 哪里:

0: Black
1: Blue
2: Green
3: Cyan
4: Red
5: Purple
6: Yellow
7: Gray
8: Silver
9: Light blue
A: Lime
B: Light cyan
C: Light red
D: Light purple
E: Light yellow
F: White

Example: 例:

color 80

Gives a silver background with black text. 给出带有黑色文字的银色背景。

Not exactly a reference but it should help you find what you're looking for on MSDN, check out: 不完全是参考,但它应该可以帮助您找到您在MSDN上寻找的内容,请查看:

http://www.gamedev.net/community/forums/topic.asp?topic_id=457528 . http://www.gamedev.net/community/forums/topic.asp?topic_id=457528

You probably want to look up "WriteConsoleOutput". 您可能想要查找“WriteConsoleOutput”。

在powershell中,write-host采用-backgroundcolor和-foregroundcolor参数

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

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