diff --git a/src/robotjs.cc b/src/robotjs.cc index 73ee9fa0..ed232ed0 100644 --- a/src/robotjs.cc +++ b/src/robotjs.cc @@ -292,6 +292,22 @@ NAN_METHOD(getPixelColor) NanReturnValue(NanNew(hex)); } +NAN_METHOD(getScreenSize) +{ + NanScope(); + + //Get display size. + MMSize displaySize = getMainDisplaySize(); + + //Create our return object. + Local obj = NanNew(); + obj->Set(NanNew("width"), NanNew(displaySize.width)); + obj->Set(NanNew("height"), NanNew(displaySize.height)); + + //Return our object with .width and .height. + NanReturnValue(obj); +} + void init(Handle target) { @@ -319,6 +335,9 @@ void init(Handle target) target->Set(NanNew("getPixelColor"), NanNew(getPixelColor)->GetFunction()); + target->Set(NanNew("getScreenSize"), + NanNew(getScreenSize)->GetFunction()); + } NODE_MODULE(robotjs, init)