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
| |/ /___ _ _| |__ ___ __ _ _ __ __| |
@@ -763,8 +755,8 @@ Napi::Object _captureScreen(const Napi::CallbackInfo &info)
763
755
throw Napi::Error::New (env, " Error: Failed to capture screen" );
764
756
}
765
757
766
- uint32_t bufferSize = ( uint32_t )( bitmap->bytewidth * bitmap->height ) ;
767
- Napi::Buffer<char > buffer = Napi::Buffer<char >::New (env, (char *)bitmap->imageBuffer , bufferSize, finalizer );
758
+ uint64_t bufferSize = bitmap->bytewidth * bitmap->height ;
759
+ Napi::Buffer<char > buffer = Napi::Buffer<char >::Copy (env, (char *)bitmap->imageBuffer , bufferSize);
768
760
769
761
Napi::Object obj = Napi::Object::New (env);
770
762
obj.Set (Napi::String::New (env, " width" ), Napi::Number::New (env, (double )bitmap->width ));
@@ -774,12 +766,12 @@ Napi::Object _captureScreen(const Napi::CallbackInfo &info)
774
766
obj.Set (Napi::String::New (env, " bytesPerPixel" ), Napi::Number::New (env, bitmap->bytesPerPixel ));
775
767
obj.Set (Napi::String::New (env, " image" ), buffer);
776
768
769
+ destroyMMBitmap (bitmap);
770
+
777
771
return obj;
778
772
}
779
773
780
774
Napi::Object Init (Napi::Env env, Napi::Object exports) {
781
- exports.Set (Napi::String::New (env, " theAnswer" ), Napi::Function::New (env, _theAnswer));
782
-
783
775
exports.Set (Napi::String::New (env, " dragMouse" ), Napi::Function::New (env, _dragMouse));
784
776
exports.Set (Napi::String::New (env, " moveMouse" ), Napi::Function::New (env, _moveMouse));
785
777
exports.Set (Napi::String::New (env, " getMousePos" ), Napi::Function::New (env, _getMousePos));
0 commit comments