Windows 10 console escape sequences VT-100

I play with the new (limited) VT-100 escape sequences support in the Windows 10 console. Supported sequences are documented at https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85 ) .aspx .

I use batch files to test functions, and I can get almost all of the documented functions to work. But I am having problems with the "View Positioning" sequences (scroll up / down). In my hands they are completely dysfunctional (no effect).

ESC[<n>S  -  Scroll Up <n> lines
ESC[<n>T  -  Scroll Down <n> lines

Can someone make them work under any circumstances, or is the MS documentation just wrong?

In addition, there are standard query sequences that MicroSoft has not documented, but seems to work.
In particular, I am interested in the following sequence, reporting the current cursor position.

ESC[6n - responds with ESC[<n>;<m>R, 
         where <n> is the row number, and <m> the column number

The answer is transmitted as keyboard input and appears on the screen, but I have no idea how to programmatically use this information. Ideally I would like to get the values <n>and <m>environment variables from a batch file.

But if anyone can demonstrate how to capture variables using any language, then I can use this knowledge to develop an effective batch file strategy.

I can get closer to the next simple script called ANSI.BAT

@echo off
setlocal enableDelayedExpansion

for /f "delims=" %%C in (
  'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x1B"'
) do set "esc=%%C"
set "csi=%esc%["

echo(Inquiry:%csi%6n
set /p "pos="
echo response=!pos:%esc%=ESC!

- CONCLUSION -

C:\test>ansi
Inquiry:
^[[3;9R
response=ESC[3;9R

C:\test>

, FOR/F, . , , - <Enter> , , SET/P. , ...

EDIT - : , , . , , , .

+4
2

Windows 10, - . , Ansi ESC[6n ESC[<n>;<m>R, Enter , SET /P, SendKeys JScript.

ESC .

EDIT: ...

@if (@CodeSegment == @Batch) @then

@echo off
title Ansi Test
setlocal EnableDelayedExpansion

for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "csi=%esc%["

echo Inquiry:%csi%6n
cscript //nologo //E:JScript "%~F0"
set /p "pos=" > NUL
echo response=!pos:%esc%=ESC!

@end

var sh = WScript.CreateObject("WScript.Shell");
sh.AppActivate("Ansi Test");
sh.SendKeys("{ENTER}");

, ...

+2

, W10.

, SET /P. xcopy /W R

@echo off
setlocal enableExtensions enableDelayedExpansion
call :inquiry
for /L %%n in (1 1 20) do (
    set "key="
    for /F "usebackq delims=" %%L in (`xcopy /L /w "%~f0" "%~f0" 2^>NUL`) do (
        if not defined key set "key=%%L"
    )
    set "key=!key:~-1!"
    set "response=!response!!key!"
    if !key!==R goto :break
)
:break
echo !response!

:
XCOPY.
, XCOPY , .

0

All Articles