Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing caret/cursor position

today I'm here to give you all a new challenge!

Just joking: my problem is the caret of the Command Prompt. [The "entire" story is in the bottom"]

Short story long, I have to move the caret positions to ECHO a new line in the same position. That's because I have to print only few strings [about three lines]; making a CLS every time it blinks because of the speed of the execution.

I tried some things, also using the <NUL SET /P "=InsertHereString", but there's always the problem of what I already ECHOed that doesn't disappear!

So here's my request: There's a method to move that blinking bunch of pixel allowing to write a string starting from a certain point of the CMD?

BOTTOM: The "entire" story is that I made a sort of installer in batch, copying and linking some applications from a removable drive. Now, I also made a status bar saying in percentage what is done. Under the status bar I want to show what actually the program is doing, but when there are [for example] a lot of file in a directory to link or copy, it makes a list instead of erasing the previous thing, so at the moment I'm simply ECHOing a " - Done!" or a" - Failed!" string next to the main string. I asked for that because in another language [C++] I found a method that I used to make a PacMan simulation. It consists in a method that want an X and an Y variable that identify the caret position in a Cartesian plane where the (0,0) position is the up-left corner of the Command Prompt.

Thanks for your time!

like image 821
ingroxd Avatar asked Jun 17 '26 03:06

ingroxd


1 Answers

BG v2.5 (unicode)

http://batch.xoo.it/t2238-BG-exe-Utility-for-Batch-Games.htm

BG.EXE is a tool for print text color in cmd.exe. It accepts regular expressions for print ascii characters. It also have useful functions.

Locate row column ::locate the position of cursor in row and column specified, zero index based.

Call it: bg Locate 0 0 and the cursor jumps there.


Or

CursorPos.exe

http://www.dostips.com/forum/viewtopic.php?f=3&t=3428

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.

like image 119
William Bettridge-Radford Avatar answered Jun 21 '26 07:06

William Bettridge-Radford