From dc52bc26aa856230bec44fc53c28f0ec0a4f1c1c Mon Sep 17 00:00:00 2001 From: Jason Stallings Date: Fri, 7 Aug 2015 16:45:51 -0500 Subject: [PATCH] Make global delays configurable. #14 --- src/robotjs.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/robotjs.cc b/src/robotjs.cc index 50a8592d..29a39707 100644 --- a/src/robotjs.cc +++ b/src/robotjs.cc @@ -188,6 +188,20 @@ NAN_METHOD(mouseToggle) NanReturnValue(NanNew("1")); } +NAN_METHOD(setMouseDelay) +{ + NanScope(); + + if (args.Length() != 1) + { + return NanThrowError("Invalid number of arguments."); + } + + mouseDelay = args[0]->Int32Value(); + + NanReturnValue(NanNew("1")); +} + /* _ __ _ _ | |/ /___ _ _| |__ ___ __ _ _ __ __| | @@ -492,6 +506,20 @@ NAN_METHOD(typeString) NanReturnValue(NanNew("1")); } +NAN_METHOD(setKeyboardDelay) +{ + NanScope(); + + if (args.Length() != 1) + { + return NanThrowError("Invalid number of arguments."); + } + + keyboardDelay = args[0]->Int32Value(); + + NanReturnValue(NanNew("1")); +} + /* ____ / ___| ___ _ __ ___ ___ _ __ @@ -560,6 +588,9 @@ void init(Handle target) target->Set(NanNew("mouseToggle"), NanNew(mouseToggle)->GetFunction()); + target->Set(NanNew("setMouseDelay"), + NanNew(setMouseDelay)->GetFunction()); + target->Set(NanNew("keyTap"), NanNew(keyTap)->GetFunction()); @@ -569,6 +600,9 @@ void init(Handle target) target->Set(NanNew("typeString"), NanNew(typeString)->GetFunction()); + target->Set(NanNew("setKeyboardDelay"), + NanNew(setKeyboardDelay)->GetFunction()); + target->Set(NanNew("getPixelColor"), NanNew(getPixelColor)->GetFunction());