iohook
iohook copied to clipboard
Identify whether the user is moving left or is moving top though mouse position is (0, 0)?
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
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).
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);
});
This is probably a feature worth implementing.