Skip to content

Commit 3cbfc50

Browse files
committed
Use global delays for mouse and keyboard functions.
1 parent b6326bc commit 3cbfc50

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/robotjs.cc

+10-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
using namespace v8;
1515

16+
//Global delays.
17+
int mouseDelay = 10;
18+
int keyboardDelay = 10;
19+
1620
/*
1721
__ __
1822
| \/ | ___ _ _ ___ ___
@@ -35,7 +39,7 @@ NAN_METHOD(moveMouse)
3539
MMPoint point;
3640
point = MMPointMake(x, y);
3741
moveMouse(point);
38-
microsleep(10);
42+
microsleep(mouseDelay);
3943

4044
NanReturnValue(NanNew("1"));
4145
}
@@ -53,7 +57,7 @@ NAN_METHOD(moveMouseSmooth)
5357
MMPoint point;
5458
point = MMPointMake(x, y);
5559
smoothlyMoveMouse(point);
56-
microsleep(10);
60+
microsleep(mouseDelay);
5761

5862
NanReturnValue(NanNew("1"));
5963
}
@@ -122,7 +126,7 @@ NAN_METHOD(mouseClick)
122126
doubleClick(button);
123127
}
124128

125-
microsleep(10);
129+
microsleep(mouseDelay);
126130

127131
NanReturnValue(NanNew("1"));
128132
}
@@ -179,7 +183,7 @@ NAN_METHOD(mouseToggle)
179183
}
180184

181185
toggleMouse(down, button);
182-
microsleep(10);
186+
microsleep(mouseDelay);
183187

184188
NanReturnValue(NanNew("1"));
185189
}
@@ -410,7 +414,7 @@ NAN_METHOD(keyTap)
410414
break;
411415
default:
412416
tapKeyCode(key, flags);
413-
microsleep(10);
417+
microsleep(keyboardDelay);
414418
}
415419

416420
NanReturnValue(NanNew("1"));
@@ -468,7 +472,7 @@ NAN_METHOD(keyToggle)
468472
break;
469473
default:
470474
toggleKeyCode(key, down, flags);
471-
microsleep(10);
475+
microsleep(keyboardDelay);
472476
}
473477

474478
NanReturnValue(NanNew("1"));

0 commit comments

Comments
 (0)