Skip to content

Commit

Permalink
Merge pull request #2 from octalmage/master
Browse files Browse the repository at this point in the history
Getting Changes
  • Loading branch information
Deltatiger committed Aug 2, 2015
2 parents 03a437a + ec1fd14 commit fd93139
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ This is a work in progress so the exported functions could change at any time be

## Installing

RobotJS uses [node-gyp](https://github.com/TooTallNate/node-gyp) for building. Please make sure you have the [required dependencies](https://github.com/TooTallNate/node-gyp/#installation) before installing.

Then install RobotJS using npm:

```
npm install robotjs
```
Expand All @@ -24,11 +28,11 @@ Get the mouse location and move it.
var robot = require("robotjs");

//Get the mouse position, returns an object with x and y.
var mouse=robot.getMousePos();
var mouse = robot.getMousePos();
console.log("Mouse is at x:" + mouse.x + " y:" + mouse.y);

//Move the mouse down by 100 pixels.
robot.moveMouse(mouse.x,mouse.y+100);
robot.moveMouse(mouse.x, mouse.y + 100);

//Left click!
robot.mouseClick();
Expand All @@ -51,7 +55,7 @@ Get pixel color under the mouse.
var robot = require("robotjs");

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

//Get pixel color in hex format.
var hex = robot.getPixelColor(mouse.x, mouse.y);
Expand All @@ -62,7 +66,7 @@ Read the [Wiki](https://github.com/octalmage/robotjs/wiki) for more information!

## Building

RobotJS uses [node-gyp](https://github.com/TooTallNate/node-gyp) for building.
node-gyp is required to build RobotJS.

Install node-gyp using npm:

Expand Down Expand Up @@ -95,7 +99,7 @@ node-gyp build

## Story

I'm a huge fan of [AutoHotkey](http://www.autohotkey.com/), and I've used it for a very long time. AutoHotkey is great for automation and it can do a bunch of things that are very difficult in other languages. For example, it's [imagesearch](https://www.autohotkey.com/docs/commands/ImageSearch.htm) and [pixel](https://www.autohotkey.com/docs/commands/PixelGetColor.htm) related functions are hard to reproduce on Mac, espscially in scripting languages. These functions are great for automating apps that can't be automated like [Netflix](http://blueshirtdesign.com/apps/autoflix/). This has never been a big deal since I've always used Windows at work, but for the past few years I've been using Mac exclusively.
I'm a huge fan of [AutoHotkey](http://www.autohotkey.com/), and I've used it for a very long time. AutoHotkey is great for automation and it can do a bunch of things that are very difficult in other languages. For example, it's [imagesearch](https://www.autohotkey.com/docs/commands/ImageSearch.htm) and [pixel](https://www.autohotkey.com/docs/commands/PixelGetColor.htm) related functions are hard to reproduce on Mac, especially in scripting languages. These functions are great for automating apps that can't be automated like [Netflix](http://blueshirtdesign.com/apps/autoflix/). This has never been a big deal since I've always used Windows at work, but for the past few years I've been using Mac exclusively.

I like AutoHotkey, but I like Node.js more. By developing RobotJS I get an AutoHotkey replacement on Mac (finally!), and I get to use my favorite language.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "robotjs",
"version": "0.2.1",
"version": "0.2.2",
"description": "Node.js Desktop Automation.",
"main": "index.js",
"scripts": {
Expand Down
48 changes: 48 additions & 0 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,54 @@ int CheckKeyCodes(char* k, MMKeyCode *key)
{
*key = K_SPACE;
}
else if (strcmp(k, "f1") == 0)
{
*key = K_F1;
}
else if (strcmp(k, "f2") == 0)
{
*key = K_F2;
}
else if (strcmp(k, "f3") == 0)
{
*key = K_F3;
}
else if (strcmp(k, "f4") == 0)
{
*key = K_F4;
}
else if (strcmp(k, "f5") == 0)
{
*key = K_F5;
}
else if (strcmp(k, "f6") == 0)
{
*key = K_F6;
}
else if (strcmp(k, "f7") == 0)
{
*key = K_F7;
}
else if (strcmp(k, "f8") == 0)
{
*key = K_F8;
}
else if (strcmp(k, "f9") == 0)
{
*key = K_F9;
}
else if (strcmp(k, "f10") == 0)
{
*key = K_F10;
}
else if (strcmp(k, "f11") == 0)
{
*key = K_F11;
}
else if (strcmp(k, "f12") == 0)
{
*key = K_F12;
}
else if (strlen(k) == 1)
{
*key = keyCodeForChar(*k);
Expand Down

0 comments on commit fd93139

Please sign in to comment.