@@ -18,8 +18,8 @@ int mouseDelay = 10;
18
18
int keyboardDelay = 10 ;
19
19
20
20
/*
21
- __ __
22
- | \/ | ___ _ _ ___ ___
21
+ __ __
22
+ | \/ | ___ _ _ ___ ___
23
23
| |\/| |/ _ \| | | / __|/ _ \
24
24
| | | | (_) | |_| \__ \ __/
25
25
|_| |_|\___/ \__,_|___/\___|
@@ -238,21 +238,21 @@ NAN_METHOD(setMouseDelay)
238
238
info.GetReturnValue ().Set (Nan::New (1 ));
239
239
}
240
240
241
- NAN_METHOD (scrollMouse)
241
+ NAN_METHOD (scrollMouse)
242
242
{
243
243
Nan::HandleScope scope;
244
244
245
245
// Get the values of magnitude and direction from the arguments list.
246
- if (info.Length () == 2 )
246
+ if (info.Length () == 2 )
247
247
{
248
248
int scrollMagnitude = info[0 ]->Int32Value ();
249
249
char *s;
250
250
251
251
Nan::Utf8String sstr (info[1 ]);
252
252
s = *sstr;
253
-
253
+
254
254
MMMouseWheelDirection scrollDirection;
255
-
255
+
256
256
if (strcmp (s, " up" ) == 0 )
257
257
{
258
258
scrollDirection = DIRECTION_UP;
@@ -265,26 +265,26 @@ NAN_METHOD(scrollMouse)
265
265
{
266
266
return Nan::ThrowError (" Invalid scroll direction specified." );
267
267
}
268
-
268
+
269
269
scrollMouse (scrollMagnitude, scrollDirection);
270
270
microsleep (mouseDelay);
271
-
271
+
272
272
info.GetReturnValue ().Set (Nan::New (1 ));
273
- }
274
- else
273
+ }
274
+ else
275
275
{
276
276
return Nan::ThrowError (" Invalid number of arguments." );
277
277
}
278
278
}
279
279
/*
280
- _ __ _ _
280
+ _ __ _ _
281
281
| |/ /___ _ _| |__ ___ __ _ _ __ __| |
282
282
| ' // _ \ | | | '_ \ / _ \ / _` | '__/ _` |
283
283
| . \ __/ |_| | |_) | (_) | (_| | | | (_| |
284
284
|_|\_\___|\__, |_.__/ \___/ \__,_|_| \__,_|
285
- |___/
285
+ |___/
286
286
*/
287
- struct KeyNames
287
+ struct KeyNames
288
288
{
289
289
const char * name;
290
290
MMKeyCode key;
@@ -323,7 +323,8 @@ static KeyNames key_names[] =
323
323
{ " shift" , K_SHIFT },
324
324
{ " space" , K_SPACE },
325
325
{ " printscreen" , K_PRINTSCREEN },
326
-
326
+ { " insert" , K_INSERT },
327
+
327
328
{ " audio_mute" , K_AUDIO_VOLUME_MUTE },
328
329
{ " audio_vol_down" , K_AUDIO_VOLUME_DOWN },
329
330
{ " audio_vol_up" , K_AUDIO_VOLUME_UP },
@@ -336,7 +337,7 @@ static KeyNames key_names[] =
336
337
{ " audio_forward" , K_AUDIO_FORWARD },
337
338
{ " audio_repeat" , K_AUDIO_REPEAT },
338
339
{ " audio_random" , K_AUDIO_RANDOM },
339
-
340
+
340
341
{ " lights_mon_up" , K_LIGHTS_MON_UP },
341
342
{ " lights_mon_down" , K_LIGHTS_MON_DOWN },
342
343
{ " lights_kbd_toggle" ,K_LIGHTS_KBD_TOGGLE },
@@ -359,7 +360,7 @@ int CheckKeyCodes(char* k, MMKeyCode *key)
359
360
*key = K_NOT_A_KEY;
360
361
361
362
KeyNames* kn = key_names;
362
- while (kn->name )
363
+ while (kn->name )
363
364
{
364
365
if (strcmp (k, kn->name ) == 0 )
365
366
{
@@ -369,7 +370,7 @@ int CheckKeyCodes(char* k, MMKeyCode *key)
369
370
kn++;
370
371
}
371
372
372
- if (*key == K_NOT_A_KEY)
373
+ if (*key == K_NOT_A_KEY)
373
374
{
374
375
return -2 ;
375
376
}
@@ -577,9 +578,9 @@ NAN_METHOD(typeStringDelayed)
577
578
{
578
579
char *str;
579
580
Nan::Utf8String string (info[0 ]);
580
-
581
+
581
582
str = *string;
582
-
583
+
583
584
size_t cpm = info[1 ]->Int32Value ();
584
585
585
586
typeStringDelayed (str, cpm);
@@ -600,12 +601,12 @@ NAN_METHOD(setKeyboardDelay)
600
601
}
601
602
602
603
/*
603
- ____
604
- / ___| ___ _ __ ___ ___ _ __
605
- \___ \ / __| '__/ _ \/ _ \ '_ \
604
+ ____
605
+ / ___| ___ _ __ ___ ___ _ __
606
+ \___ \ / __| '__/ _ \/ _ \ '_ \
606
607
___) | (__| | | __/ __/ | | |
607
608
|____/ \___|_| \___|\___|_| |_|
608
-
609
+
609
610
*/
610
611
611
612
/* *
@@ -626,7 +627,7 @@ NAN_METHOD(getPixelColor)
626
627
{
627
628
return Nan::ThrowError (" Invalid number of arguments." );
628
629
}
629
-
630
+
630
631
MMBitmapRef bitmap;
631
632
MMRGBHex color;
632
633
@@ -641,9 +642,9 @@ NAN_METHOD(getPixelColor)
641
642
bitmap = copyMMBitmapFromDisplayInRect (MMRectMake (x, y, 1 , 1 ));
642
643
643
644
color = MMRGBHexAtPoint (bitmap, 0 , 0 );
644
-
645
+
645
646
char hex[7 ];
646
-
647
+
647
648
padHex (color, hex);
648
649
649
650
destroyMMBitmap (bitmap);
@@ -665,18 +666,18 @@ NAN_METHOD(getScreenSize)
665
666
info.GetReturnValue ().Set (obj);
666
667
}
667
668
668
- NAN_METHOD (captureScreen)
669
+ NAN_METHOD (captureScreen)
669
670
{
670
671
size_t x;
671
672
size_t y;
672
673
size_t w;
673
674
size_t h;
674
-
675
- // If user has provided screen coords, use them!
675
+
676
+ // If user has provided screen coords, use them!
676
677
if (info.Length () == 4 )
677
678
{
678
679
// TODO: Make sure requested coords are within the screen bounds, or we get a seg fault.
679
- // An error message is much nicer!
680
+ // An error message is much nicer!
680
681
681
682
x = info[0 ]->Int32Value ();
682
683
y = info[1 ]->Int32Value ();
@@ -688,15 +689,15 @@ NAN_METHOD(captureScreen)
688
689
// We're getting the full screen.
689
690
x = 0 ;
690
691
y = 0 ;
691
-
692
+
692
693
// Get screen size.
693
694
MMSize displaySize = getMainDisplaySize ();
694
695
w = displaySize.width ;
695
696
h = displaySize.height ;
696
697
}
697
-
698
+
698
699
MMBitmapRef bitmap = copyMMBitmapFromDisplayInRect (MMRectMake (x, y, w, h));
699
-
700
+
700
701
uint32_t bufferSize = bitmap->bytewidth * bitmap->height ;
701
702
Local<Object> buffer = Nan::NewBuffer ((char *)bitmap->imageBuffer , bufferSize, destroyMMBitmapBuffer, NULL ).ToLocalChecked ();
702
703
@@ -707,17 +708,17 @@ NAN_METHOD(captureScreen)
707
708
Nan::Set (obj, Nan::New (" bitsPerPixel" ).ToLocalChecked (), Nan::New<Number>(bitmap->bitsPerPixel ));
708
709
Nan::Set (obj, Nan::New (" bytesPerPixel" ).ToLocalChecked (), Nan::New<Number>(bitmap->bytesPerPixel ));
709
710
Nan::Set (obj, Nan::New (" image" ).ToLocalChecked (), buffer);
710
-
711
+
711
712
info.GetReturnValue ().Set (obj);
712
713
}
713
714
714
715
/*
715
- ____ _ _
716
- | __ )(_) |_ _ __ ___ __ _ _ __
717
- | _ \| | __| '_ ` _ \ / _` | '_ \
716
+ ____ _ _
717
+ | __ )(_) |_ _ __ ___ __ _ _ __
718
+ | _ \| | __| '_ ` _ \ / _` | '_ \
718
719
| |_) | | |_| | | | | | (_| | |_) |
719
- |____/|_|\__|_| |_| |_|\__,_| .__/
720
- |_|
720
+ |____/|_|\__|_| |_| |_|\__,_| .__/
721
+ |_|
721
722
*/
722
723
723
724
class BMP
@@ -732,7 +733,7 @@ class BMP
732
733
};
733
734
734
735
// Convert object from Javascript to a C++ class (BMP).
735
- BMP buildBMP (Local<Object> info)
736
+ BMP buildBMP (Local<Object> info)
736
737
{
737
738
Local<Object> obj = Nan::To<v8::Object>(info).ToLocalChecked ();
738
739
@@ -804,7 +805,7 @@ NAN_MODULE_INIT(InitAll)
804
805
805
806
Nan::Set (target, Nan::New (" mouseToggle" ).ToLocalChecked (),
806
807
Nan::GetFunction (Nan::New<FunctionTemplate>(mouseToggle)).ToLocalChecked ());
807
-
808
+
808
809
Nan::Set (target, Nan::New (" scrollMouse" ).ToLocalChecked (),
809
810
Nan::GetFunction (Nan::New<FunctionTemplate>(scrollMouse)).ToLocalChecked ());
810
811
@@ -831,10 +832,10 @@ NAN_MODULE_INIT(InitAll)
831
832
832
833
Nan::Set (target, Nan::New (" getScreenSize" ).ToLocalChecked (),
833
834
Nan::GetFunction (Nan::New<FunctionTemplate>(getScreenSize)).ToLocalChecked ());
834
-
835
+
835
836
Nan::Set (target, Nan::New (" captureScreen" ).ToLocalChecked (),
836
837
Nan::GetFunction (Nan::New<FunctionTemplate>(captureScreen)).ToLocalChecked ());
837
-
838
+
838
839
Nan::Set (target, Nan::New (" getColor" ).ToLocalChecked (),
839
840
Nan::GetFunction (Nan::New<FunctionTemplate>(getColor)).ToLocalChecked ());
840
841
}
0 commit comments