in reply to Re^2: Unable to capture mouse events in Win32::Console
in thread Unable to capture mouse events in Win32::Console

It took me a while to figure that one out as well. It's the character-based y coordinate relative to the first (top) line of text in the console, assuming your scroll bar is at the very top. So if your window is 25 lines tall but your history is 50 characters tall total, then if you scroll to the top , it will say the y is line 0, and if you scroll to the bottom, it will say the line is 49.

When I originally had a \n in my ->Write() string, I was confused why the y coordinate would start increasing and "never" stop, even as I moved the cursor back up the screen. So I changed it to a \r instead, so the text wouldn't scroll the screen, and it suddenly made perfect sense, as I manually scrolled or intentionally moved down a line for printing (typing an ENTER, because the keyboard events still kept \n). (I also didn't realize until I did that -- though it should have been obvious, even from the x coordinate -- that the coordinates were in characters, not in pixels.)

update: My original reply was assuming you were talking about the mouse coordinates from @console_events. Sorry I misread. But yes, the current x and current y, in the info array as well, are still relative to the top-left of the whole buffer, so the whole size and current location can be outside the window dimensions.

Replies are listed 'Best First'.
Re^4: Unable to capture mouse events in Win32::Console
by fireblood (Scribe) on Apr 29, 2022 at 16:48 UTC

    Hi pryrt, excellent! That explains it all. So to determine the actual Y-coordinate within the console window all that will be required is to subtract the Y-coordinate in the buffer from the Y-coordinate of the top of the console window in the buffer.

    Thanks much!