独自のエコーコマンドを作成できます。
デスクトップ上ColourText.bas
というファイルに以下の行を入れてください。
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public Module MyApplication
Public Declare Function GetStdHandle Lib "kernel32" Alias "GetStdHandle" (ByVal nStdHandle As Long) As Long
Public Declare Function SetConsoleTextAttribute Lib "kernel32" Alias "SetConsoleTextAttribute" (ByVal hConsoleOutput As Long, ByVal wAttributes As Long) As Long
Public Const STD_ERROR_HANDLE = -12&
Public Const STD_INPUT_HANDLE = -10&
Public Const STD_OUTPUT_HANDLE = -11&
Sub Main()
Dim hOut as Long
Dim Ret as Long
Dim Colour As Long
Dim Colour1 As Long
Dim Text As String
hOut = GetStdHandle(STD_OUTPUT_HANDLE)
Colour = CLng("&h" & Split(Command(), " ")(0))
Colour1 = Clng("&h" & Split(Command(), " ")(1))
Text = Mid(Command(), 7)
Ret = SetConsoleTextAttribute(hOut, Colour)
Console.Out.WriteLine(text)
Ret = SetConsoleTextAttribute(hOut, Colour1)
End Sub
End Module
保存し、コマンドプロンプトで次のように入力します。
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%userprofile%\desktop\ColourText.exe" "%userprofile%\desktop\ColourText.bas" /verbose
ColourText.exeというファイルがデスクトップに表示されます。 Windowsフォルダに移動します。
使用するには、2つの文字コードを使用して、たとえば01
ではなく1
の色を設定する必要があります。
ColourText ColourOfText ColourOfTextWhenFinished Text
EGは、任意のテキストを通過しないことにより、白を青色に設定し、次にグレーにブルーで仕上げ、白いテキストに赤。
ColourText F1 F1
ColourText F2 71 This is green on white
または
ColourText F1 F1
cls
ColourText F4 F4
Echo Hello
Echo Hello today
ColourText F1 F1
またCLS
コマンドが面白いとなります。パラメータなしのColor
コマンドは、すべての色をスタートアップカラーにリセットします。
カラーコードを取得するには、次の番号を一緒に追加します。プログラマーモードで電卓を使用してください。これらは16進数です。 Red + Blue + FG Intensity = 13 = Dのように一緒に加えることができます.10+は使用されなかったので、背景は黒です。色コードは2文字でなければなりません(例:08
は8
ではありません)。
FOREGROUND_RED = &H4 ' text color contains red.
FOREGROUND_INTENSITY = &H8 ' text color is intensified.
FOREGROUND_GREEN = &H2 ' text color contains green.
FOREGROUND_BLUE = &H1 ' text color contains blue.
BACKGROUND_BLUE = &H10 ' background color contains blue.
BACKGROUND_GREEN = &H20 ' background color contains green.
BACKGROUND_INTENSITY = &H80 ' background color is intensified.
BACKGROUND_RED = &H40 ' background color contains red.
の
可能な重複http://stackoverflow.com/questions/2048509/how-to-echo-with-different-colors-in-the([Windowsのコマンドラインで異なる色でエコー方法] -windows-command-line) –
これを見てください==> http://stackoverflow.com/questions/41309768/batch-file-to-run-ping-command-and-output-to-text-aswell/ 41316112#41316112 – Hackoo