Skip to content
Marcos Garcia de Lima edited this page Aug 13, 2015 · 43 revisions

Functions


Keyboard

keyTap(key)

Press a single key.

Arguments

  • key - Accepts backspace, enter, up, down, left, right, escape, delete, home, end, pageup, and pagedown.

keyToggle(key, modifier)

Press a single key.

Arguments

  • key - Accepts backspace, enter, up, down, left, right, escape, delete, home, end, pageup, and pagedown.
  • modifier (optional) - Accepts alt, command (win), control, and shift.

typeString(string)

Arguments

  • string - the string to send

Mouse

moveMouse(x, y)

Moves mouse to x, y instantly.

Arguments

  • x
  • y

Examples

var robot = require("robotjs");

//Move the mouse to 100, 100 on the screen. 
robot.moveMouse(100, 100);

moveMouseSmooth(x, y)

Moves mouse to x, y human like.

Arguments

  • x
  • y

mouseClick(button, double)

Clicks the mouse.

Arguments

  • button (optional) - Accepts left, right, or middle. Defaults to left.
  • double (optional) - Set to true to perform a double click. Defaults to false.

Examples

var robot = require("robotjs");

robot.mouseClick();

mouseToggle(down, button)

Toggles mouse button.

Arguments

  • down (optional) - Accepts down or up. Defaults to down.
  • button (optional) - Accepts left, right, or middle. Defaults to left.

Examples

var robot = require("robotjs");

robot.mouseToggle("down");

setTimeout(function()
{
    robot.mouseToggle("up");

}, 2000);

getMousePos()

Gets the mouse coordinates.

Return

Returns an object with keys x and y.

Examples

var robot = require("robotjs");

var mouse=robot.getMousePos();
console.log("Mouse is at x:" + mouse.x + " y:" + mouse.y);

Screen

getPixelColor(x, y)

Gets the pixel color at x, y.

Arguments

  • x
  • y

Return

Returns the hex color code of the pixel at x, y.

getScreenSize()

Gets the screen width and height.

Return

Returns an object with .width and .height.

Clone this wiki locally