From e55e2d21b0d2cce3345942eb82ecd043477ce064 Mon Sep 17 00:00:00 2001 From: Jason Stallings Date: Fri, 30 Jan 2015 18:29:21 -0600 Subject: [PATCH] Proposed syntax for #4. --- README.md | 6 +++--- index.js | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 015af272..855540c9 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@ Get the mouse location and move it. var robot = require("robotjs"); //Get the mouse position, retuns an object with x and y. -var mouse=robot.getMousePos(); +var mouse=robot.mouse.pos(); 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.mouse.move(mouse.x,mouse.y+100); //Left click! -robot.mouseClick(); +robot.mouse.click(); ``` ## Building diff --git a/index.js b/index.js index e761fb6b..09a2e6ec 100644 --- a/index.js +++ b/index.js @@ -1 +1,17 @@ -module.exports = require('./build/Release/robotjs.node'); +var robotjs = require('./build/Release/robotjs.node'); + +//Objects. +var mouse = {}, keyboard = {}; + +//Mouse. +mouse.click = robotjs.mouseClick; +mouse.move = robotjs.moveMouse; +mouse.pos = robotjs.getMousePos; + +//Keyboard. +keyboard.tap = robotjs.keyTap; +keyboard.type = robotjs.typeString; + +//Exports. +module.exports.mouse = mouse; +module.exports.keyboard = keyboard; \ No newline at end of file