- Sub print(text,ForegroundColor,BackgroundColor,Style1,style2)
- Set Color = CreateObject("Scripting.Dictionary")'抄自@老刘一号 TerminalController.vbs
- Set Color1 = CreateObject("Scripting.Dictionary")
- Set Styles = CreateObject("Scripting.Dictionary")
- With Color'back
- .Add "Black", 40
- .Add "Red", 41
- .Add "Green", 42
- .Add "Yellow", 43
- .Add "Blue", 44
- .Add "Magenta", 45
- .Add "Cyan", 46
- .Add "White", 47
- .Add "BrightBlack", 100
- .Add "BrightRed", 101
- .Add "BrightGreen", 102
- .Add "BrightYellow", 103
- .Add "BrightBlue", 104
- .Add "BrightMagenta", 105
- .Add "BrightCyan", 106
- .Add "BrightWhite", 107
- .Add "Default", 49
- End With
- With color1'front
- .Add "Black", 30
- .Add "Red", 31
- .Add "Green", 32
- .Add "Yellow", 33
- .Add "Blue", 34
- .Add "Magenta", 35
- .Add "Cyan", 36
- .Add "White", 37
- .Add "BrightBlack", 90
- .Add "BrightRed", 91
- .Add "BrightGreen", 92
- .Add "BrightYellow", 93
- .Add "BrightBlue", 94
- .Add "BrightMagenta", 95
- .Add "BrightCyan", 96
- .Add "BrightWhite", 97
- .Add "Default", 39
- End With
- With styles
- .Add "normal", 0
- .Add "bold", 1
- .Add "dim", 2
- .Add "italic", 3
- .Add "underline", 4
- .Add "blink", 5
- .Add "reverse", 7
- .Add "invisible", 8
- .Add "strikeout", 9
- End With
- If IsNumeric(ForegroundColor) Then
- 'do nothing
- ElseIf VarType(ForegroundColor) = 8 Then
- If color1.exists(ForegroundColor) Then
- ForegroundColor = color1.item(ForegroundColor)
- Else
- ForegroundColor = 39
- End If
- Else
- ForegroundColor = 39
- End If
- BackgroundColor = formatcolor(color,BackgroundColor)
- ForegroundColor = formatcolor(color1,ForegroundColor)
- style1 = formatcolor(styles,style1)
- style2 = formatcolor(styles,style2)
- WScript.stdout.write Chr(27) & "[4;" & ForegroundColor & ";" & BackgroundColor & ";" & style1 & ";" & style2 & "m" & text & Chr(27) & "[0m"
- End Sub
- Function formatcolor(obj,ByVal input)
- If IsNumeric(input) Then
- 'do nothing
- ElseIf VarType(input) = 8 Then
- If obj.exists(input) Then
- input = obj.item(input)
- Else
- input = 0
- End If
- Else
- input = 0
- End If
- formatcolor = input
- End Function
-
-
- print "1","White","Red",1,4
- 'print [输出文字],[前景颜色],[背景颜色],[样式1],[样式2]
- WScript.stdin.readline
复制代码 ps:为什么我用不了TerminalController.vbs? |