0

how can get mouse coordinates on the console?

Notice : only the console, not all the screen

HANDLE hOut;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD xy
CONSOLE_SCREEN_BUFFER_INFO cbsi;
if (GetConsoleScreenBufferInfo(hOut, &cbsi))
    xy = cbsi.dwCursorPosition;

I used this

Asesh
  • 3,186
  • 2
  • 21
  • 31
MPERSIA
  • 187
  • 1
  • 15
  • 2
    *A COORD structure that contains the column and row coordinates of the cursor in the console screen buffer.* - The console screen buffer is not the screen. You won't get window coordinates from the console API. You could use window APIs to do that. – chris Aug 19 '18 at 00:54
  • how? Can you explain more? I'm beginner – MPERSIA Aug 19 '18 at 01:02
  • 2
    The console deals in a table of characters rather than pixels. I'm saying if you want functions that deal in pixels, the other parts of the Win32 API provide those instead of anything console-specific. In particular, I was getting at [`ScreenToClient`](https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-screentoclient). If you're doing something console-related, it's a bit questionable to need client (not window, my bad) coordinates. The console has its own mouse input mechanism with `ReadConsoleInput`. – chris Aug 19 '18 at 01:08
  • 2
    Depending on the coordinate system you want your mouse position in, [How can I get the mouse position in a console program?](https://stackoverflow.com/q/6285270/1889329) could be what you're looking for. But that's not clear from the question you asked. – IInspectable Aug 19 '18 at 09:34

0 Answers0