To start, .NET essentially wraps the native Win API for mouse programming as an answer to a related SO question explains.
Win API expresses absolute (versus relative) mouse coordinates as normalized 16-bit values (i.e. between 0 and 65,535 since 2^16 = 65,536). See Win API mouse_event
documentation.
Now .NET System.Drawing.PointF
's X
and Y
properties are of type Single
. Huh? Well, one way to express a 16-bit value is with a real number between 0 and 1, which can then be multiplied by 65,535 (i.e. the maximum 16-bit value)...to arrive at the corresponding value between 0 and 65,535. This is why you see p.X * 65535
and p.Y * 65535
.
To map the 16-bit absolute X and Y mouse coordinates to the screen at hand, they need to be scaled to it since it is not 65,536 x 65,536 pixels: dividing them by ScreenSize.Width
and ScreenSize.Height
respectively achieves this.
There you have it I think.
If you are interested in reading more about all this, Daniel Moth's blog has a reference implementation for moving the mouse cursor and related explanations that you might want to consider in relation to the code you're trying to understand. Also, you might find another related SO question and the answers to it informative.