Hi all!
I tested the CursorPos program and suddenly came across a question to which I have not yet found an answer.
The problem is as follows.
CursorPos description wrote:
Get or set cursor position.
CursorPos [[±]col [±]row]
If no parameter is given, return current cursor position as col+(row<<16) in ERRORLEVEL.
If any coordinate have sign, the position given is relative to the current one.
If cursor is moved, the Ascii code of the character at new position is returned in ERRORLEVEL.
Me debug printing did not help me answer the question - how to get Ascii code of the character at new cursor position.
My debug script is inherently very simple as it consists of repeating blocks.
Code: Select all
:: chkCursorPos.cmd
@echo off
setlocal enableDelayedExpansion
pushd %~dp0
cls
echo.A
echo. B
echo. C
echo. D
<nul set /p =qwErty
CursorPos.exe
::GetCoords Cols= Lines=
set /a "$X=%ErrorLevel%&0xFFFF, $Y=(%ErrorLevel%>>16)&0xFFFF, $E=%ErrorLevel%"
>%~nx0.log (
echo.step0: backup current cursor pos?
echo.CursorPos.exe
echo.current pos:
set $
echo.::::::::::::::::::::
)
>nul pause
CursorPos.exe 0 0
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
echo.step1: move new pos 0 0 - simbol "A"
echo.CursorPos.exe 0 0
echo.
set _
echo.====================
)
>nul pause
CursorPos.exe +1 +1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
echo.step2: move new pos +1 +1 - simbol "B"
echo.3: CursorPos.exe +1 +1
set _
echo.-------------------
)
>nul pause
CursorPos.exe 1 1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
echo.step2': move pos 1 1 - simbol "B"
echo.3: CursorPos.exe 1 1
set _
echo.:::::::::::::::::::
)
>nul pause
CursorPos.exe +1 +1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
echo.step3: move new pos +1 +1 - simbol "C"
echo.CursorPos.exe +1 +1
set _
echo.-------------------
)
>nul pause
CursorPos.exe 1 1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
echo.step3': move pos 1 1 - simbol "B"
echo.3: CursorPos.exe 1 1
set _
echo.:::::::::::::::::::
)
>nul pause
CursorPos.exe +2 +2
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
echo.step4: move new pos +2 +2 - simbol "D"
echo.CursorPos.exe +2 +2
set _
echo.-------------------
)
>nul pause
CursorPos.exe -1 +1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
echo.step5: move new pos -1 +1 - simbol "E"
echo.CursorPos.exe -1 +1
set _
echo.-------------------
)
>nul pause
CursorPos.exe %$E%
>>%~nx0.log (
echo.step6: restore pos
echo.CursorPos.exe %$E%
set $
echo.====================
)
>nul pause
exit /b
Debug txt-file:
Code: Select all
step0: backup current cursor pos?
CursorPos.exe
current pos:
$E=262150
$X=6
$Y=4
::::::::::::::::::::
step1: move new pos 0 0 - simbol "A"
CursorPos.exe 0 0
_E=262150
_X=6
_Y=4
====================
step2: move new pos +1 +1 - simbol "B"
3: CursorPos.exe +1 +1
_E=0
_X=0
_Y=0
-------------------
step2': move pos 1 1 - simbol "B"
3: CursorPos.exe 1 1
_E=65537
_X=1
_Y=1
:::::::::::::::::::
step3: move new pos +1 +1 - simbol "C"
CursorPos.exe +1 +1
_E=65537
_X=1
_Y=1
-------------------
step3': move pos 1 1 - simbol "B"
3: CursorPos.exe 1 1
_E=131074
_X=2
_Y=2
:::::::::::::::::::
step4: move new pos +2 +2 - simbol "D"
CursorPos.exe +2 +2
_E=65537
_X=1
_Y=1
-------------------
step5: move new pos -1 +1 - simbol "E"
CursorPos.exe -1 +1
_E=196611
_X=3
_Y=3
-------------------
step6: restore pos
CursorPos.exe 262150
$E=262150
$X=6
$Y=4
====================
ErrorLevel values are 5-6-digit numbers in the debug log.
It does not seem that they, in addition to the coordinates, contain an Ascii code character.
Has anyone got the Ascii character codes via CursorPos? Give an example.