Convert image coordinates to screen coordinates
masterThe Image.prototype.toScreenPoint(point, target) method translates a coordinate relative to the image into an absolute screen coordinate. This is useful when working with high-DPI displays or scaled screenshots.
point: An object{ x, y }representing the local coordinate within the image.target(optional): An object containingwidthandheightused to calculate scaling offsets.
It uses the image's internal scaleX, scaleY, screenX, and screenY properties to ensure the returned point correctly maps to the physical monitor position.
const img = robotjs.screen.capture();
const localPoint = { x: 10, y: 10 };
const screenPoint = img.toScreenPoint(localPoint);
console.log(`Screen coordinates: ${screenPoint.x}, ${screenPoint.y}`);