Skip to content

Commit

Permalink
Make sure coords are in bounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Jan 8, 2016
1 parent 4a5572f commit b1f2852
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ NAN_METHOD(getPixelColor)
size_t x = info[0]->Int32Value();
size_t y = info[1]->Int32Value();

if (!pointVisibleOnMainDisplay(MMPointMake(x, y)))
{
return Nan::ThrowError("Requested coordinates are outside the main screen's dimensions.");
}

bitmap = copyMMBitmapFromDisplayInRect(MMRectMake(x, y, 1, 1));

color = MMRGBHexAtPoint(bitmap, 0, 0);
Expand Down

0 comments on commit b1f2852

Please sign in to comment.