Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the position of the cursor in a console app?

Tags:

c#

console

I would like to be able to check that the position of the cursor hasn't moved past a certain point. I haven't been able to find anything that gives the position of the text cursor via google. I'm not really sure where else to look.

like image 400
scott Avatar asked May 07 '12 14:05

scott


People also ask

How do I change cursor position?

Use the SetCursorPosition method to specify where the next write operation in the console window is to begin. If the specified cursor position is outside the area that is currently visible in the console window, the window origin changes automatically to make the cursor visible.

How do I change the cursor position in C++?

In windows you should use windows api. from there, use SetCursorPos() for it. Show activity on this post. Look at ncurses library for creating text-based user interfaces.


2 Answers

Look at the various methods and properties of the Console class. Specifically, using Console.CursorLeft and Console.CursorTop, you can get and set the position of the cursor.

like image 121
Chris Dunaway Avatar answered Sep 20 '22 09:09

Chris Dunaway


Use Console.CursorLeft and Console.CursorTop

Please look at this MSDN link for more information

http://msdn.microsoft.com/en-us/library/system.console.aspx

like image 28
Cinchoo Avatar answered Sep 19 '22 09:09

Cinchoo