批处理中的特殊字符

批处理中的特殊字符

我使用的是 Windows 7,我想用这样的特殊字符创建菜单、进度条等。该怎么做?

在此处输入图片描述

答案1

重点是 - 你需要使用 UTF-8 格式,看一看

步骤 1] 以“UTF 8”格式创建一个新的 CMD 脚本。(PsPad 或 Notepad++ 编辑器可以执行此操作)

步骤 2] 在第一行留一个空白行。UTF 8 标头存储在那里。

步骤3]复制粘贴以下代码:

@echo off
CHCP 65001
:: *****************************************************************************
:: * Author: Gustaaf von Pickartz.                                             *
:: * Date Created: 22nd July, 2012.                                            *
:: * ------------------------------------------------------------------------- *
:: * This program is provided as is and for fair use distribution.             *
:: * Give credit where credit is due to the author in your own script.         *
:: * ------------------------------------------------------------------------- *
:: *****************************************************************************
SETLOCAL ENABLEDELAYEDEXPANSION

:: Progress Bar
 SET PRG0=[░░░░░░░░░░]
 SET PRG1=[▓░░░░░░░░░]
 SET PRG2=[▓▓░░░░░░░░]
 SET PRG3=[▓▓▓░░░░░░░]
 SET PRG4=[▓▓▓▓░░░░░░]
 SET PRG5=[▓▓▓▓▓░░░░░]
 SET PRG6=[▓▓▓▓▓▓░░░░]
 SET PRG7=[▓▓▓▓▓▓▓░░░]
 SET PRG8=[▓▓▓▓▓▓▓▓░░]
 SET PRG9=[▓▓▓▓▓▓▓▓▓░]
SET PRG10=[▓▓▓▓▓▓▓▓▓▓]

:: Star
 SET STR1=/
 SET STR2=--
 SET STR3=\
 SET STR4=^|

:: Please note there are special ASCII insertions in the SET BKSPC= declaration below. 80x backspace characters are inserted. ASCII Value 08=[BS]
:: Be sure to verify they are still there when you cut and paste from the web with your text editor (Notepad++ or PsPad). Insert them if missing, otherwise this script will not work...
SET BKSPC=


:Begin_Main
echo.
echo.
Echo Simple Animated star.
FOR /L %%I IN (1,1,400) DO (
<NUL (SET/P Z= PROGRESS: │)
<NUL (SET/P Z=%BKSPC%)
<NUL (SET/P Z= PROGRESS: /)
<NUL (SET/P Z=%BKSPC%)
<NUL (SET/P Z= PROGRESS: ─)
<NUL (SET/P Z=%BKSPC%)
<NUL (SET/P Z= PROGRESS: \)
<NUL (SET/P Z=%BKSPC%)
)

echo.
echo.
Echo Simple Progress bar indicator
FOR /L %%I IN (0,1,10) DO (
IF %%I LEQ 9 (SET TIC=0%%I) ELSE (SET TIC=%%I)
<NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I!)
>NUL PING -n 2 localhost
<NUL (SET/P Z=%BKSPC%)
)

echo.
echo.
Echo Combined Progress bar and animated star...
FOR /L %%I IN (0,1,10) DO (
IF %%I LEQ 9 (SET TIC=0%%I) ELSE (SET TIC=%%I)
<NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I!)
<NUL (SET/P Z=%BKSPC%)
    FOR /L %%J IN (1,1,400) DO (
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! │)
    <NUL (SET/P Z=%BKSPC%)
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! /)
    <NUL (SET/P Z=%BKSPC%)
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! ─)
    <NUL (SET/P Z=%BKSPC%)
    <NUL (SET/P Z=[!TIC!/10] PROGRESS: !PRG%%I! \)
    <NUL (SET/P Z=%BKSPC%)
    )
<NUL (SET/P Z=%BKSPC%)
)

步骤 4] 确保在 SET BKSPC= 处“插入”80x 个退格 ASCII 字符(http://columbia.edu/kermit/ascii.html

步骤 5] 确保将 CMD 控制台字体设置为 True Type 字体,而不是光栅字体。

相关内容