Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
59 lines (43 sloc) 1.23 KB
layout title categories lead_text
docs
Examples
docs

Mouse

{% highlight javascript %} // 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) - 10; var width = screenSize.width;

for (var x = 0; x < width; x++) { y = height * Math.sin((twoPI * x) / width) + height; robot.moveMouse(x, y); } {% endhighlight %}

Keyboard

{% highlight javascript %} // Type "Hello World" then press enter. var robot = require("robotjs");

// Type "Hello World". robot.typeString("Hello World");

// Press enter. robot.keyTap("enter"); {% endhighlight %}

Screen

{% highlight javascript %} // Get pixel color under the mouse. var robot = require("robotjs");

// Get mouse position. var mouse = robot.getMousePos();

// Get pixel color in hex format. var hex = robot.getPixelColor(mouse.x, mouse.y); console.log("#" + hex + " at x:" + mouse.x + " y:" + mouse.y); {% endhighlight %}

Read the Docs for more information!