From a3346abb64c8f454cbdc5dc09087fc31b98978d5 Mon Sep 17 00:00:00 2001 From: Jason Stallings Date: Sun, 4 Oct 2015 07:55:00 -0500 Subject: [PATCH] Accept "up" or "down" for direction. --- src/robotjs.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/robotjs.cc b/src/robotjs.cc index 3a882111..2bd71b88 100644 --- a/src/robotjs.cc +++ b/src/robotjs.cc @@ -199,7 +199,22 @@ NAN_METHOD(scrollMouse) if(info.Length() == 2) { int scrollMagnitude = info[0]->Int32Value(); - int scrollDirection = info[1]->Int32Value(); + char *s = (*v8::String::Utf8Value(info[1]->ToString())); + + MMMouseWheelDirection scrollDirection; + + if (strcmp(s, "up") == 0) + { + scrollDirection = DIRECTION_UP; + } + else if (strcmp(s, "down") == 0) + { + scrollDirection = DIRECTION_DOWN; + } + else + { + return Nan::ThrowError("Invalid scroll direction specified."); + } scrollMouse(scrollMagnitude, scrollDirection); microsleep(mouseDelay);