Skip to main content

Module virtualdesk

Module virtualdesk 

Source
Expand description

Normalizing a session’s physical pixel into the grid Windows takes.

SendInput with MOUSEEVENTF_ABSOLUTE does not accept pixels. It accepts a number from 0 to 65535 on each axis, and the rectangle that number is measured against depends on one flag: without MOUSEEVENTF_VIRTUALDESK it is the primary monitor, and with it, the virtual desktop — the bounding box of every monitor, whose origin is the top-left of the primary display and whose coordinates are therefore negative for anything placed above or to the left of it.

A session records global physical pixels, which is the virtual desktop’s own space, so the whole conversion is this normalization. It lives here rather than in the injector for the reason everything else does: the part that decides where to click must be testable without a screen, and this particular arithmetic has a famous off-by-one worth pinning for every input rather than for a few examples.

The off-by-one. Pixels span 0..=(dimension − 1), so the divisor is dimension − 1, not dimension. Dividing by the full width leaves the rightmost column and bottom row unreachable and every other pixel fractionally short — a drift that grows with distance from the origin and is invisible on a small screen. Rounding rather than truncating is the other half of the same rule.

Structs§

VirtualDesktop
The bounding box of every monitor attached to this machine, as Windows reports it — SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN.

Enums§

NormalizeError
Why a point could not be expressed as an absolute mouse event.

Functions§

normalize
Convert a global physical pixel into the absolute pair SendInput takes alongside MOUSEEVENTF_VIRTUALDESK.