@@ -496,7 +496,7 @@ Napi::Number _keyToggle(const Napi::CallbackInfo &info)
496496 MMKeyFlags flags = MOD_NONE;
497497 MMKeyCode key;
498498
499- bool down;
499+ bool down = false ;
500500
501501 // Get arguments from JavaScript.
502502 std::string keyName = info[0 ].As <Napi::String>();
@@ -576,7 +576,7 @@ Napi::Number _typeStringDelayed(const Napi::CallbackInfo &info)
576576 std::string stringToType = info[0 ].As <Napi::String>();
577577 size_t cpm = info[1 ].As <Napi::Number>().Int32Value ();
578578
579- typeStringDelayed (stringToType.c_str (), cpm);
579+ typeStringDelayed (stringToType.c_str (), ( unsigned int ) cpm);
580580
581581 return Napi::Number::New (env, 1 );
582582}
@@ -613,8 +613,8 @@ Napi::Object _getScreenSize(const Napi::CallbackInfo &info)
613613
614614 // Create our return object.
615615 Napi::Object obj = Napi::Object::New (env);
616- obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, displaySize.width ));
617- obj.Set (Napi::String::New (env, " height" ), Napi::Number::New (env, displaySize.height ));
616+ obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, ( double ) displaySize.width ));
617+ obj.Set (Napi::String::New (env, " height" ), Napi::Number::New (env, ( double ) displaySize.height ));
618618
619619 return obj;
620620}
@@ -660,7 +660,7 @@ Napi::Number _highlight(const Napi::CallbackInfo &info)
660660 y = info[1 ].As <Napi::Number>().Int32Value ();
661661 width = info[2 ].As <Napi::Number>().Int32Value ();
662662 height = info[3 ].As <Napi::Number>().Int32Value ();
663- duration = info[4 ].As <Napi::Number>().Int64Value ();
663+ duration = ( int ) info[4 ].As <Napi::Number>().Int64Value ();
664664 opacity = info[5 ].As <Napi::Number>().FloatValue ();
665665
666666 highlight (x, y, width, height, duration, opacity);
@@ -673,7 +673,7 @@ Napi::Number _getActiveWindow(const Napi::CallbackInfo &info) {
673673 Napi::Env env = info.Env ();
674674
675675 WindowHandle windowHandle = getActiveWindow ();
676- return Napi::Number::New (env, windowHandle);
676+ return Napi::Number::New (env, ( double ) windowHandle);
677677}
678678
679679Napi::Array _getWindows (const Napi::CallbackInfo &info) {
@@ -683,7 +683,7 @@ Napi::Array _getWindows(const Napi::CallbackInfo &info) {
683683 auto arr = Napi::Array::New (env, windowHandles.size ());
684684
685685 for (size_t idx = 0 ; idx < windowHandles.size (); ++idx) {
686- arr[idx] = windowHandles[idx];
686+ arr[( uint32_t ) idx] = windowHandles[idx];
687687 }
688688
689689 return arr;
@@ -696,10 +696,10 @@ Napi::Object _getWindowRect(const Napi::CallbackInfo &info) {
696696 MMRect windowRect = getWindowRect (windowHandle);
697697
698698 Napi::Object obj = Napi::Object::New (env);
699- obj.Set (Napi::String::New (env, " x" ), Napi::Number::New (env, windowRect.origin .x ));
700- obj.Set (Napi::String::New (env, " y" ), Napi::Number::New (env, windowRect.origin .y ));
701- obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, windowRect.size .width ));
702- obj.Set (Napi::String::New (env, " height" ), Napi::Number::New (env, windowRect.size .height ));
699+ obj.Set (Napi::String::New (env, " x" ), Napi::Number::New (env, ( double ) windowRect.origin .x ));
700+ obj.Set (Napi::String::New (env, " y" ), Napi::Number::New (env, ( double ) windowRect.origin .y ));
701+ obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, ( double ) windowRect.size .width ));
702+ obj.Set (Napi::String::New (env, " height" ), Napi::Number::New (env, ( double ) windowRect.size .height ));
703703
704704 return obj;
705705}
@@ -758,14 +758,18 @@ Napi::Object _captureScreen(const Napi::CallbackInfo &info)
758758 }
759759
760760 MMBitmapRef bitmap = copyMMBitmapFromDisplayInRect (MMRectMake (x, y, w, h));
761+
762+ if (bitmap == NULL ) {
763+ throw Napi::Error::New (env, " Error: Failed to capture screen" );
764+ }
761765
762- uint32_t bufferSize = bitmap->bytewidth * bitmap->height ;
766+ uint32_t bufferSize = ( uint32_t )( bitmap->bytewidth * bitmap->height ) ;
763767 Napi::Buffer<char > buffer = Napi::Buffer<char >::New (env, (char *)bitmap->imageBuffer , bufferSize, finalizer);
764768
765769 Napi::Object obj = Napi::Object::New (env);
766- obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, bitmap->width ));
767- obj.Set (Napi::String::New (env, " height" ), Napi::Number::New (env, bitmap->height ));
768- obj.Set (Napi::String::New (env, " byteWidth" ), Napi::Number::New (env, bitmap->bytewidth ));
770+ obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, ( double ) bitmap->width ));
771+ obj.Set (Napi::String::New (env, " height" ), Napi::Number::New (env, ( double ) bitmap->height ));
772+ obj.Set (Napi::String::New (env, " byteWidth" ), Napi::Number::New (env, ( double ) bitmap->bytewidth ));
769773 obj.Set (Napi::String::New (env, " bitsPerPixel" ), Napi::Number::New (env, bitmap->bitsPerPixel ));
770774 obj.Set (Napi::String::New (env, " bytesPerPixel" ), Napi::Number::New (env, bitmap->bytesPerPixel ));
771775 obj.Set (Napi::String::New (env, " image" ), buffer);
0 commit comments