0

I'm trying to get the position of the mouse cursor, relative to the console window, with the upper left corner of the console window being point 0, 0. I've gotten the cursor position, but now I need the position of the console to make the position relative to the window.

How would I get the position of the console window? I will need to do this many times a second, so preferably it would not be api call heavy.

Joseph Long
  • 143
  • 1
  • 9
  • 3
    It seems a little odd that you're wanting to get the position of a window - a GUI construct - in a console app. What if someone ran the app from some context that didn't have a window, like calling it in a scheduled batch file of some kind? – Joe Sewell Jul 03 '19 at 17:29
  • 1
    What if there's more than one console window open? –  Jul 03 '19 at 17:37
  • 1
    @JoeSewell That's a good point. I originally interpreted the question to mean they want the position of an *arbitrary* console window. I hadn't considered their console application would want to get the position of its *own* console window. –  Jul 03 '19 at 17:39
  • @JoeSewell It's a game engine I've been writing to run exclusively in the console. I do realize how useless that sounds. – Joseph Long Jul 03 '19 at 18:08
  • @Amy Yes, I want to get the position of it's own window. – Joseph Long Jul 03 '19 at 19:38
  • I think this would get you started: https://stackoverflow.com/a/1277609/2557128 You may also need [this](https://support.microsoft.com/en-us/help/124103/how-to-obtain-a-console-window-handle-hwnd) as referenced in the comments. – NetMage Jul 03 '19 at 21:52

0 Answers0