Get cursor position
Posted: 10 Jun 2021 13:20
Hello people,
I have this script to get the cursor position, but it is quite slow. Is there a way to make it faster, or even better, native batch?
Ty,
Lordoa
I have this script to get the cursor position, but it is quite slow. Is there a way to make it faster, or even better, native batch?
Code: Select all
@echo off
title Get cursor
cls
setlocal enabledelayedexpansion
if not "%1" == "" goto sendenter
set strlen=for /l %%a in (1,1,2) do if "%%a" == "2" (for /f "tokens=1* delims=," %%b in ("^!args^!") do (if "%%c" == "" (set %%b=0) else ((set tmp$=%%c^& for %%p in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (if not "^!tmp$:~%%p,1^!" == "" (set /a len$+=%%p ^& set tmp$=^^!tmp$:~%%p^^!)))^& set %%b=^^!len$^^!))) else set len$=1^&set args=
FOR /F "delims=#" %%a IN ('"prompt #$E# & for %%a IN (1) do rem"') do set esc=%%a
:menu
echo(
echo(
echo(
pause>nul|set/p =Fourth line, 29th character:
<nul set/p=%esc%[6n
start /b "" "%cd%\%~nx0" cookie
set /p cursorloc=
echo Did it work?
%strlen%result,%cursorloc%
echo %result%
for /f "tokens=1,2,3 delims=[]R;" %%a in ("%cursorloc%") do echo %%b and %%c
pause
:sendenter
powershell -nologo $wshell = New-Object -ComObject wscript.shell; $wshell.Sendkeys('~')
exit
Lordoa