Back in the early days of computing, the "Blink" effect was a standard way to signal critical errors or hardware failures. While modern UI design often discourages blinking because it can be distracting or inaccessible to some users, it remains a powerful tool for specialized Batch scripts, such as emergency alarm monitors or "Self-Destruct" sequence simulations, where you need to grab the user's attention immediately.
In this guide, we will demonstrate how to create a blinking text effect using modern ANSI Escape Codes and a manual fallback approach.
The ANSI Blink Code
Modern Windows terminals support the SGR (Select Graphic Rendition) code for blinking.
- Blink (Slow):
ESC[5m - Reset:
ESC[0m
Method 1: ANSI Blink Code
This approach uses the standard ANSI blink escape sequence. While it may not produce a visible blink on most Windows terminals, it is the standards-compliant method and will work in terminals that support it (such as some third-party terminal emulators or remote SSH sessions to Linux systems).
Implementation Script
@echo off
setlocal enabledelayedexpansion
:: Capture the Escape character (ASCII 27)
for /F "delims=" %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
if not defined ESC (
echo [ERROR] Could not generate ANSI escape character.
pause
exit /b 1
)
:: Define formatting variables
set "BLINK=!ESC![5m"
set "BOLD=!ESC![1m"
set "RED=!ESC![91m"
set "RESET=!ESC![0m"
echo.
echo Standard text output.
echo.
echo !BOLD!!RED!!BLINK! WARNING: CRITICAL OVERHEAT DETECTED !RESET!
echo.
echo Monitoring continued...
endlocal
pauseMethod 2: Manual Blink with ANSI (Recommended for Windows)
Since the ANSI ESC[5m code is not rendered by most Windows terminals, the most reliable way to produce a visible blink effect is to use a loop that alternates between showing and hiding the text. This version uses ANSI cursor positioning to overwrite text in place, avoiding the full-screen flicker caused by cls.
Manual Blink Script
@echo off
setlocal enabledelayedexpansion
for /F "delims=" %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
if not defined ESC (
echo [ERROR] Could not generate ANSI escape character.
pause
exit /b 1
)
set "BOLD=!ESC![1m"
set "RED=!ESC![91m"
set "RESET=!ESC![0m"
set "msg=*** CRITICAL ALERT: SYSTEM OVERHEAT ***"
:: Blank string must be at least as long as the message to fully erase it
set "blank= "
cls
echo Press Ctrl+C to stop.
echo.
:: Save the line number where the message will blink
:: We use line 3 (after the header and blank line)
set "msgRow=3"
:blink_loop
:: Show the message
<nul set /p "=!ESC![!msgRow!;1H!BOLD!!RED!!msg!!RESET!"
:: Wait ~500ms (192.0.2.1 is a non-routable RFC 5737 address, forcing a timeout)
ping -n 1 -w 500 192.0.2.1 >nul
:: Hide the message by overwriting with spaces
<nul set /p "=!ESC![!msgRow!;1H!blank:~0,40!"
:: Wait ~500ms
ping -n 1 -w 500 192.0.2.1 >nul
goto blink_loopMethod 3: Manual Blink with CLS (Legacy Fallback)
If you are on an older version of Windows (like Windows 7) where ANSI codes are not available, you can create a manual blink using cls. This causes full-screen flicker but works on all Windows versions.
Legacy Blink Script
@echo off
set "msg=CONNECTING TO SERVER..."
echo Press Ctrl+C to stop.
:blink_loop
:: Show the message
cls
echo %msg%
ping -n 1 -w 500 192.0.2.1 >nul
:: Hide the message
cls
echo.
ping -n 1 -w 500 192.0.2.1 >nul
goto blink_loopWhen to Use Blink (And When to Avoid It)
Use Blink When:
- Displaying a catastrophic failure (e.g., "DATABASE WIPED").
- In "Kiosk" mode scripts where a terminal is used as a status board and needs to draw attention from across a room.
- For fun "Hacker" or retro-themed scripts.
Avoid Blink When:
- Displaying standard information (it makes it hard to read).
- In tools used by people with photosensitive epilepsy or other visual sensitivities.
- For non-critical warnings where a simple red bold color would suffice.
Summary
The blinking text effect is the ultimate "HEY, LOOK HERE" signal in a text-based environment. Since the ANSI ESC[5m blink code is not supported by most Windows terminals, the most reliable approach on Windows is a manual show/hide loop using ANSI cursor positioning to avoid screen flicker. For legacy systems without ANSI support, a cls-based loop provides a basic fallback. Use blinking sparingly, and it remains one of the most effective tools in a Batch programmer's visual arsenal.