Search code examples
javascriptjquerymouseeventparallax

Simulating circular mouse movement with jQuery?


Is there a way to make ones mouse cursor move repeatedly in a circular formation using jQuery?

Going to be used to test Parallax.js's load on ones GPU / CPU.


Solution

  • There's no way to control user mouse with Javascript. The intention behind this is to prevent clickjacking and cursorjacking. Consider the following scenario:

    1) User clicks a link.
    2) Javascript forces the mouse to move to another link prior to click.
    3) User ends up clicking a link with lots of NSFW stuff and gets fired.

    Also, consider another scenario from the point of view of Cookieclicker :

    1) User injects a cursor automation script into console.
    2) User proceeds to play the game without making a single click themselves.


    Alternative to Cursor Control

    However, instead of a method to move your mouse cursor, you can look up Javascript page automation testing for frameworks that can simulate events; including cursor movements. This would be a third party application that can control your mouse for you. You can also use jQuery trigger for custom events that triggers when origin-x or y changes.

    Parallax Engine that reacts to the orientation of a smart device. Where no gyroscope or motion detection hardware is available, the position of the cursor is used instead.

    We see from it's documentation that Parallax is a library that reacts to cursor events. Furthermore, from what I see, it seems that cursor positions are translated into origin-x and origin-y inputs; default of both values is 0.5 (the center of the viewport), x - 0 is left, 1 is right, y - 0 is top, 1 is bottom. Instead of creating automation for the cursor, it would be even better to automate those values to simulate the required inputs for some motion.