1
1
#include < napi.h>
2
2
3
- #include " buffer_finalizer.h"
4
3
#include " keypress.h"
5
4
#include " microsleep.h"
6
5
#include " MMBitmap.h"
11
10
12
11
int mouseDelay = 10 ;
13
12
int keyboardDelay = 10 ;
14
- static BufferFinalizer<char > finalizer;
15
13
16
14
/*
17
15
__ __
@@ -243,12 +241,6 @@ Napi::Number _scrollMouse(const Napi::CallbackInfo &info)
243
241
return Napi::Number::New (env, 1 );
244
242
}
245
243
246
- Napi::Number _theAnswer (const Napi::CallbackInfo &info) {
247
- Napi::Env env = info.Env ();
248
-
249
- return Napi::Number::New (env, 42 );
250
- }
251
-
252
244
/*
253
245
_ __ _ _
254
246
| |/ /___ _ _| |__ ___ __ _ _ __ __| |
@@ -761,8 +753,8 @@ Napi::Object _captureScreen(const Napi::CallbackInfo &info)
761
753
throw Napi::Error::New (env, " Error: Failed to capture screen" );
762
754
}
763
755
764
- uint32_t bufferSize = ( uint32_t )( bitmap->bytewidth * bitmap->height ) ;
765
- Napi::Buffer<char > buffer = Napi::Buffer<char >::New (env, (char *)bitmap->imageBuffer , bufferSize, finalizer );
756
+ uint64_t bufferSize = bitmap->bytewidth * bitmap->height ;
757
+ Napi::Buffer<char > buffer = Napi::Buffer<char >::Copy (env, (char *)bitmap->imageBuffer , bufferSize);
766
758
767
759
Napi::Object obj = Napi::Object::New (env);
768
760
obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, (double )bitmap->width ));
@@ -772,12 +764,12 @@ Napi::Object _captureScreen(const Napi::CallbackInfo &info)
772
764
obj.Set (Napi::String::New (env, " bytesPerPixel" ), Napi::Number::New (env, bitmap->bytesPerPixel ));
773
765
obj.Set (Napi::String::New (env, " image" ), buffer);
774
766
767
+ destroyMMBitmap (bitmap);
768
+
775
769
return obj;
776
770
}
777
771
778
772
Napi::Object Init (Napi::Env env, Napi::Object exports) {
779
- exports.Set (Napi::String::New (env, " theAnswer" ), Napi::Function::New (env, _theAnswer));
780
-
781
773
exports.Set (Napi::String::New (env, " dragMouse" ), Napi::Function::New (env, _dragMouse));
782
774
exports.Set (Napi::String::New (env, " moveMouse" ), Napi::Function::New (env, _moveMouse));
783
775
exports.Set (Napi::String::New (env, " getMousePos" ), Napi::Function::New (env, _getMousePos));
0 commit comments