diff --git a/index.js b/index.js index 2d9113c9..69342b84 100644 --- a/index.js +++ b/index.js @@ -19,8 +19,17 @@ bitmap.prototype.colorAt = function(x, y) return robotjs.getColor(this, x, y); }; -module.exports.screen.capture = function() +module.exports.screen.capture = function(x, y, width, height) { - b = robotjs.captureScreen(); + //If coords have been passed, use them. + if (typeof x !== "undefined" && typeof y !== "undefined" && typeof width !== "undefined" && typeof height !== "undefined") + { + b = robotjs.captureScreen(x, y, width, height); + } + else + { + b = robotjs.captureScreen(); + } + return new bitmap(b.width, b.height, b.byteWidth, b.bitsPerPixel, b.bytesPerPixel, b.image); }; \ No newline at end of file