Search code examples
javascriptpythonpyautogui

Can javascript recognize mouse movements?


I would like to know if there is a way to "monitor" mouse movements. I'm developing automation in python and I don't know if there's a way for javascript to recognize what I'm planning to do. I think teleporting the mouse pointer could give some hint of automation. I think disguising the movement could be an option. I plan to use Pyautogui, Selenium wouldn't run what I need.


Solution

  • Html Code

    <div onmousemove="myFunction(event)"></div>
    

    Js code

    function myFunction(e) {
      var x = e.clientX;
      var y = e.clientY;
      var coor = "Coordinates: (" + x + "," + y + ")";
      document.getElementById("demo").innerHTML = coor;
    }