I am using the user32.dll function GetCursorPos to get the SCREEN coordinates of my cursor. I need to know if the cursor is at the top of the screen (with multiple monitor setups included).
However, when I try to test for the Y coordinate that GetCursorPos gives me, I never got a coordinate less than 250 or so, even though I moved the cursor around all the screen borders of both my screens.
I have thought the upper left corner of my main screen would be [0,0] and Y would grow as I got lower on my screen, why does it start with such a high number?
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetCursorPos(out POINT lpPoint);
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
public POINT(int x, int y)
{
this.X = x;
this.Y = y;
}
}
private void Whatever() {
POINT lMousePosition;
GetCursorPos(out lMousePosition)
}
I expect the output of the function to be less than 10 in the Y coordinate somewhere... its not. Why?
EDIT:
I have found the solution. The function returns the correct values, but my usage of breakpoints to look at the said value changed it from the one I wanted to saw when the breakpoint got hit.