Skip to content

Instantly share code, notes, and snippets.

@octalmage
Created October 18, 2015 14:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save octalmage/5e0de00a64b84a5e4b7c to your computer and use it in GitHub Desktop.
Save octalmage/5e0de00a64b84a5e4b7c to your computer and use it in GitHub Desktop.
RobotJS - Move the mouse across the screen as a sine wave.
//Move the mouse across the screen as a sine wave.
var robot = require("robotjs");
//Speed up the mouse.
robot.setMouseDelay(2);
var twoPI = Math.PI * 2.0;
var screenSize = robot.getScreenSize();
var height = (screenSize.height / 2) - 40;
var width = screenSize.width;
for (var x = 0; x < width; x++)
{
y = height * Math.sin((twoPI * x) / width) + height;
robot.moveMouse(x, y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment