0

For example, if I wanted to make it so that to click (or hover) on something, I had to click 50 pixels to the left or below it.

The motivation is that a game I'm playing incorrectly detects the mouse location in menus, so I'm hoping that offsetting the mouse manually might fix it.

music2myear
  • 49,799

1 Answers1

0

You must first track the current mouse location and then add an offset to the detected location for your click operation.

Here's how you can detect the location of your pointer.

var pointerX = -1;
var pointerY = -1;
document.onmousemove = function(event) {
    pointerX = event.pageX;
    pointerY = event.pageY;
}
setInterval(pointerCheck, 1000);
function pointerCheck() {
    console.log('Cursor at: '+pointerX+', '+pointerY);
}

You can test clicks with cps test. Once you log the pointer position, now see what is the exact offset you are having on your screen in pixels.