iohook icon indicating copy to clipboard operation
iohook copied to clipboard

Identify whether the user is moving left or is moving top though mouse position is (0, 0)?

Open edeink opened this issue 6 years ago • 3 comments

For Example:

My screen size is 200 * 200, then I move to the position (0, 0) and get the message

{ button: 0, clicks: 0, x: 0, y: 0, type: 'mousemove' }

Then I try to move left or move top, but still get the message:

{ button: 0, clicks: 0, x: 0, y: 0, type: 'mousemove' }

Can I Identify whether the user is moving left or is moving top

edeink avatar Jan 03 '19 03:01 edeink

Hello!

You could compare two successive calls (positions x1, y1 and x2, y2) to deduce if the user was moving left (x2 < x1) or top (y2 > y1).

Djiit avatar Jan 06 '19 17:01 Djiit

Thanks for your answer.

That's the skill I used before : " If I found that the user is move to the point ,such as (0, 0); then I auto move the mouse (may be use robotjs ) to the near point like ( 10, 10 ) and then compare points."

But is it possible that I just move to (0, 0) and identify the user is move top or left? both posA and posB are (0, 0)

It's a little similar with

/*
* Env : chrome
* Thought I am at (0, 0), I try to move left, then event.movementX is -1,
* and If I try to move top, the event.movementY is -1
*/
window.addEventListener('mousemove', function(event) {
      console.log(event.movementX, event.movementY);
});

edeink avatar Jan 07 '19 12:01 edeink

This is probably a feature worth implementing.

ash0x0 avatar Jun 11 '21 20:06 ash0x0