Skip to content

Commit d94ca48

Browse files
committed
Added getScreenSize, closes #25.
This returns and object with the width and height. Example: { width: 1280, height: 800 }
1 parent 845a838 commit d94ca48

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/robotjs.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,22 @@ NAN_METHOD(getPixelColor)
292292
NanReturnValue(NanNew(hex));
293293
}
294294

295+
NAN_METHOD(getScreenSize)
296+
{
297+
NanScope();
298+
299+
//Get display size.
300+
MMSize displaySize = getMainDisplaySize();
301+
302+
//Create our return object.
303+
Local<Object> obj = NanNew<Object>();
304+
obj->Set(NanNew<String>("width"), NanNew<Number>(displaySize.width));
305+
obj->Set(NanNew<String>("height"), NanNew<Number>(displaySize.height));
306+
307+
//Return our object with .width and .height.
308+
NanReturnValue(obj);
309+
}
310+
295311
void init(Handle<Object> target)
296312
{
297313

@@ -319,6 +335,9 @@ void init(Handle<Object> target)
319335
target->Set(NanNew<String>("getPixelColor"),
320336
NanNew<FunctionTemplate>(getPixelColor)->GetFunction());
321337

338+
target->Set(NanNew<String>("getScreenSize"),
339+
NanNew<FunctionTemplate>(getScreenSize)->GetFunction());
340+
322341
}
323342

324343
NODE_MODULE(robotjs, init)

0 commit comments

Comments
 (0)