node-native-win-utils 1.3.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -83
- package/binding.gyp +3 -0
- package/dist/dirnameLocal.cjs +4 -0
- package/dist/dirnameLocal.d.cts +1 -0
- package/dist/dirnameLocal.d.mts +1 -0
- package/dist/dirnameLocal.mjs +2 -0
- package/dist/{index.js → index.cjs} +49 -17
- package/dist/{index.d.ts → index.d.cts} +25 -12
- package/dist/index.d.mts +191 -0
- package/dist/index.mjs +177 -0
- package/dist/keyCodes.d.mts +101 -0
- package/dist/keyCodes.mjs +201 -0
- package/node22.json +16 -0
- package/package.json +22 -9
- package/prebuilds/win32-x64/node-native-win-utils.node +0 -0
- package/prebuilds/win32-x64/tesseract.dll +0 -0
- package/prebuilds/win32-x64/tiff.dll +0 -0
- package/src/cpp/keyboard.cpp +141 -140
- package/src/cpp/main.cpp +11 -3
- package/src/cpp/{capturewindow.cpp → screenshot.cpp} +174 -2
- package/src/cpp/tesseract.cpp +49 -0
- package/src/dirnameLocal.mts +3 -0
- package/src/index.mts +454 -0
- package/src/keyCodes.mts +203 -0
- package/include/opencv2/core/affine.hpp +0 -678
- package/include/opencv2/core/async.hpp +0 -105
- package/include/opencv2/core/base.hpp +0 -664
- package/include/opencv2/core/bindings_utils.hpp +0 -325
- package/include/opencv2/core/bufferpool.hpp +0 -40
- package/include/opencv2/core/check.hpp +0 -170
- package/include/opencv2/core/core.hpp +0 -48
- package/include/opencv2/core/core_c.h +0 -3128
- package/include/opencv2/core/cuda/block.hpp +0 -211
- package/include/opencv2/core/cuda/border_interpolate.hpp +0 -722
- package/include/opencv2/core/cuda/color.hpp +0 -309
- package/include/opencv2/core/cuda/common.hpp +0 -131
- package/include/opencv2/core/cuda/datamov_utils.hpp +0 -113
- package/include/opencv2/core/cuda/detail/color_detail.hpp +0 -2018
- package/include/opencv2/core/cuda/detail/reduce.hpp +0 -365
- package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +0 -502
- package/include/opencv2/core/cuda/detail/transform_detail.hpp +0 -392
- package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +0 -191
- package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +0 -121
- package/include/opencv2/core/cuda/dynamic_smem.hpp +0 -88
- package/include/opencv2/core/cuda/emulation.hpp +0 -269
- package/include/opencv2/core/cuda/filters.hpp +0 -293
- package/include/opencv2/core/cuda/funcattrib.hpp +0 -79
- package/include/opencv2/core/cuda/functional.hpp +0 -805
- package/include/opencv2/core/cuda/limits.hpp +0 -128
- package/include/opencv2/core/cuda/reduce.hpp +0 -209
- package/include/opencv2/core/cuda/saturate_cast.hpp +0 -292
- package/include/opencv2/core/cuda/scan.hpp +0 -258
- package/include/opencv2/core/cuda/simd_functions.hpp +0 -869
- package/include/opencv2/core/cuda/transform.hpp +0 -75
- package/include/opencv2/core/cuda/type_traits.hpp +0 -90
- package/include/opencv2/core/cuda/utility.hpp +0 -230
- package/include/opencv2/core/cuda/vec_distance.hpp +0 -232
- package/include/opencv2/core/cuda/vec_math.hpp +0 -923
- package/include/opencv2/core/cuda/vec_traits.hpp +0 -288
- package/include/opencv2/core/cuda/warp.hpp +0 -139
- package/include/opencv2/core/cuda/warp_reduce.hpp +0 -76
- package/include/opencv2/core/cuda/warp_shuffle.hpp +0 -162
- package/include/opencv2/core/cuda.hpp +0 -1279
- package/include/opencv2/core/cuda.inl.hpp +0 -763
- package/include/opencv2/core/cuda_stream_accessor.hpp +0 -86
- package/include/opencv2/core/cuda_types.hpp +0 -144
- package/include/opencv2/core/cv_cpu_dispatch.h +0 -381
- package/include/opencv2/core/cv_cpu_helper.h +0 -550
- package/include/opencv2/core/cvdef.h +0 -973
- package/include/opencv2/core/cvstd.hpp +0 -190
- package/include/opencv2/core/cvstd.inl.hpp +0 -197
- package/include/opencv2/core/cvstd_wrapper.hpp +0 -154
- package/include/opencv2/core/detail/async_promise.hpp +0 -71
- package/include/opencv2/core/detail/dispatch_helper.impl.hpp +0 -49
- package/include/opencv2/core/detail/exception_ptr.hpp +0 -27
- package/include/opencv2/core/directx.hpp +0 -184
- package/include/opencv2/core/dualquaternion.hpp +0 -979
- package/include/opencv2/core/dualquaternion.inl.hpp +0 -487
- package/include/opencv2/core/eigen.hpp +0 -402
- package/include/opencv2/core/fast_math.hpp +0 -433
- package/include/opencv2/core/hal/hal.hpp +0 -256
- package/include/opencv2/core/hal/interface.h +0 -190
- package/include/opencv2/core/hal/intrin.hpp +0 -939
- package/include/opencv2/core/hal/intrin_avx.hpp +0 -3177
- package/include/opencv2/core/hal/intrin_avx512.hpp +0 -3090
- package/include/opencv2/core/hal/intrin_cpp.hpp +0 -3321
- package/include/opencv2/core/hal/intrin_forward.hpp +0 -191
- package/include/opencv2/core/hal/intrin_lasx.hpp +0 -3236
- package/include/opencv2/core/hal/intrin_msa.hpp +0 -1887
- package/include/opencv2/core/hal/intrin_neon.hpp +0 -2610
- package/include/opencv2/core/hal/intrin_rvv.hpp +0 -3320
- package/include/opencv2/core/hal/intrin_rvv071.hpp +0 -2545
- package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +0 -2080
- package/include/opencv2/core/hal/intrin_sse.hpp +0 -3467
- package/include/opencv2/core/hal/intrin_sse_em.hpp +0 -180
- package/include/opencv2/core/hal/intrin_vsx.hpp +0 -1608
- package/include/opencv2/core/hal/intrin_wasm.hpp +0 -2782
- package/include/opencv2/core/hal/msa_macros.h +0 -1558
- package/include/opencv2/core/hal/simd_utils.impl.hpp +0 -186
- package/include/opencv2/core/llapi/llapi.h +0 -102
- package/include/opencv2/core/mat.hpp +0 -3775
- package/include/opencv2/core/mat.inl.hpp +0 -3422
- package/include/opencv2/core/matx.hpp +0 -1536
- package/include/opencv2/core/neon_utils.hpp +0 -128
- package/include/opencv2/core/ocl.hpp +0 -917
- package/include/opencv2/core/ocl_genbase.hpp +0 -69
- package/include/opencv2/core/opencl/ocl_defs.hpp +0 -82
- package/include/opencv2/core/opencl/opencl_info.hpp +0 -212
- package/include/opencv2/core/opencl/opencl_svm.hpp +0 -81
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +0 -602
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +0 -146
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +0 -371
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +0 -272
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +0 -62
- package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +0 -42
- package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +0 -53
- package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +0 -53
- package/include/opencv2/core/opencl/runtime/opencl_core.hpp +0 -84
- package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +0 -47
- package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +0 -53
- package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +0 -47
- package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +0 -48
- package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +0 -42
- package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +0 -166
- package/include/opencv2/core/opengl.hpp +0 -733
- package/include/opencv2/core/openvx/ovx_defs.hpp +0 -48
- package/include/opencv2/core/operations.hpp +0 -610
- package/include/opencv2/core/optim.hpp +0 -302
- package/include/opencv2/core/ovx.hpp +0 -28
- package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +0 -72
- package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +0 -153
- package/include/opencv2/core/parallel/parallel_backend.hpp +0 -90
- package/include/opencv2/core/persistence.hpp +0 -1350
- package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +0 -30
- package/include/opencv2/core/private.cuda.hpp +0 -169
- package/include/opencv2/core/private.hpp +0 -896
- package/include/opencv2/core/quaternion.hpp +0 -1696
- package/include/opencv2/core/quaternion.inl.hpp +0 -1063
- package/include/opencv2/core/saturate.hpp +0 -180
- package/include/opencv2/core/simd_intrinsics.hpp +0 -87
- package/include/opencv2/core/softfloat.hpp +0 -514
- package/include/opencv2/core/sse_utils.hpp +0 -652
- package/include/opencv2/core/traits.hpp +0 -417
- package/include/opencv2/core/types.hpp +0 -2457
- package/include/opencv2/core/types_c.h +0 -2126
- package/include/opencv2/core/utility.hpp +0 -1229
- package/include/opencv2/core/utils/allocator_stats.hpp +0 -29
- package/include/opencv2/core/utils/allocator_stats.impl.hpp +0 -158
- package/include/opencv2/core/utils/buffer_area.private.hpp +0 -136
- package/include/opencv2/core/utils/configuration.private.hpp +0 -22
- package/include/opencv2/core/utils/filesystem.hpp +0 -82
- package/include/opencv2/core/utils/filesystem.private.hpp +0 -66
- package/include/opencv2/core/utils/fp_control.private.hpp +0 -29
- package/include/opencv2/core/utils/fp_control_utils.hpp +0 -69
- package/include/opencv2/core/utils/instrumentation.hpp +0 -125
- package/include/opencv2/core/utils/lock.private.hpp +0 -119
- package/include/opencv2/core/utils/logger.defines.hpp +0 -42
- package/include/opencv2/core/utils/logger.hpp +0 -218
- package/include/opencv2/core/utils/logtag.hpp +0 -28
- package/include/opencv2/core/utils/plugin_loader.private.hpp +0 -165
- package/include/opencv2/core/utils/tls.hpp +0 -235
- package/include/opencv2/core/utils/trace.hpp +0 -252
- package/include/opencv2/core/utils/trace.private.hpp +0 -421
- package/include/opencv2/core/va_intel.hpp +0 -75
- package/include/opencv2/core/version.hpp +0 -26
- package/include/opencv2/core/vsx_utils.hpp +0 -1047
- package/include/opencv2/core.hpp +0 -3365
- package/include/opencv2/imgcodecs/imgcodecs.hpp +0 -48
- package/include/opencv2/imgcodecs/imgcodecs_c.h +0 -1
- package/include/opencv2/imgcodecs/ios.h +0 -59
- package/include/opencv2/imgcodecs/legacy/constants_c.h +0 -54
- package/include/opencv2/imgcodecs/macosx.h +0 -20
- package/include/opencv2/imgcodecs.hpp +0 -407
- package/include/opencv2/imgproc/bindings.hpp +0 -34
- package/include/opencv2/imgproc/detail/gcgraph.hpp +0 -395
- package/include/opencv2/imgproc/hal/hal.hpp +0 -246
- package/include/opencv2/imgproc/hal/interface.h +0 -46
- package/include/opencv2/imgproc/imgproc.hpp +0 -48
- package/include/opencv2/imgproc/imgproc_c.h +0 -1177
- package/include/opencv2/imgproc/segmentation.hpp +0 -141
- package/include/opencv2/imgproc/types_c.h +0 -659
- package/include/opencv2/imgproc.hpp +0 -5035
- package/include/opencv2/opencv_modules.hpp +0 -17
- package/libs/libjpeg-turbo.lib +0 -0
- package/libs/libpng.lib +0 -0
- package/libs/opencv_core470.lib +0 -0
- package/libs/opencv_imgcodecs470.lib +0 -0
- package/libs/opencv_imgproc470.lib +0 -0
- package/libs/zlib.lib +0 -0
- /package/dist/{keyCodes.js → keyCodes.cjs} +0 -0
- /package/dist/{keyCodes.d.ts → keyCodes.d.cts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
[![License][license-src]][license-href]
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
|
|
5
5
|
#### USDT TRC20 - TYAJ3K3MZraJhWimxxeCKcJ2SYABkVsrzi
|
|
6
6
|
#### USDT TON - UQDokuYZXr4OHvfslDqUoFYcp1_F8tcjQPk_TvqSSDk7SIa7
|
|
@@ -67,9 +67,7 @@ To use the package, import the necessary functions, types, and classes:
|
|
|
67
67
|
|
|
68
68
|
import {
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
keyUpHandler,
|
|
70
|
+
KeyboardListener
|
|
73
71
|
|
|
74
72
|
getWindowData,
|
|
75
73
|
|
|
@@ -93,38 +91,30 @@ OpenCV,
|
|
|
93
91
|
|
|
94
92
|
|
|
95
93
|
|
|
96
|
-
##
|
|
94
|
+
## Keyboard Event Listener
|
|
97
95
|
|
|
98
96
|
|
|
99
97
|
|
|
100
|
-
The package provides
|
|
98
|
+
The package provides KeyboardListener singletone class, which allow you to register event listeners for key down and key up events, respectively. The event callbacks receive the `keyCode` as a parameter:
|
|
101
99
|
|
|
102
100
|
|
|
103
101
|
|
|
104
102
|
```javascript
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
console.log("Key up:", keyCode);
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// Key up: 8
|
|
127
|
-
|
|
104
|
+
const listener = KeyboardListener.listener()
|
|
105
|
+
|
|
106
|
+
listener.on("keyDown", (data: {
|
|
107
|
+
keyCode: number;
|
|
108
|
+
keyName: string;
|
|
109
|
+
}) => {
|
|
110
|
+
//your code
|
|
111
|
+
})
|
|
112
|
+
listener.on("keyUp", (data: {
|
|
113
|
+
keyCode: number;
|
|
114
|
+
keyName: string;
|
|
115
|
+
}) => {
|
|
116
|
+
//your code
|
|
117
|
+
})
|
|
128
118
|
```
|
|
129
119
|
|
|
130
120
|
## Key Press
|
|
@@ -473,18 +463,16 @@ Writes the current image to a file specified by the `path`.
|
|
|
473
463
|
|
|
474
464
|
| Function | Parameters | Return Type |
|
|
475
465
|
|-----------------|----------------------------------------------------------------------------------------------|-------------|
|
|
476
|
-
|
|
|
477
|
-
| keyUpHandler | `callback: (keyCode: number) => void` | `void` |
|
|
478
|
-
| getWindowData | `windowName: string` | `WindowData`|
|
|
466
|
+
| getWindowData | `windowName: string` | `WindowData`|
|
|
479
467
|
| captureWindow | `windowName: string, outputPath: string` | `void` |
|
|
480
468
|
| mouseMove | `posX: number, posY: number` | `boolean` |
|
|
481
469
|
| mouseClick | `button?: "left" \| "middle" \| "right"` | `boolean` |
|
|
482
|
-
| mouseDrag | `startX: number, startY: number, endX: number, endY: number, speed?: number`
|
|
470
|
+
| mouseDrag | `startX: number, startY: number, endX: number, endY: number, speed?: number` | `boolean` |
|
|
483
471
|
| typeString | `stringToType: string, delay?: number` | `boolean` |
|
|
484
|
-
| captureWindowN | `windowName: string`
|
|
485
|
-
| keyPress | `keyCode: number, repeat?: number`
|
|
486
|
-
|
|
487
|
-
|
|
472
|
+
| captureWindowN | `windowName: string` | `Buffer` |
|
|
473
|
+
| keyPress | `keyCode: number, repeat?: number` | `boolean` |
|
|
474
|
+
| textRecognition | `trainedDataPath: string, dataLang: string, imagePath: string` | `string` |
|
|
475
|
+
| captureScreenToFile | `path: string` | `boolean` |
|
|
488
476
|
|
|
489
477
|
|
|
490
478
|
## Examples
|
|
@@ -493,7 +481,10 @@ Writes the current image to a file specified by the `path`.
|
|
|
493
481
|
|
|
494
482
|
Here are some examples of using the package:
|
|
495
483
|
|
|
496
|
-
|
|
484
|
+
```javascript
|
|
485
|
+
console.log(textRecognition(path.join(__dirname, 'traineddata'), 'eng', path.join(__dirname, 'images', '1.jpg'))) // ---> <recognized text>
|
|
486
|
+
|
|
487
|
+
```
|
|
497
488
|
|
|
498
489
|
```javascript
|
|
499
490
|
|
|
@@ -577,10 +568,6 @@ Please note that the above example demonstrates the usage of different methods a
|
|
|
577
568
|
|
|
578
569
|
import {
|
|
579
570
|
|
|
580
|
-
keyDownHandler,
|
|
581
|
-
|
|
582
|
-
keyUpHandler,
|
|
583
|
-
|
|
584
571
|
getWindowData,
|
|
585
572
|
|
|
586
573
|
captureWindow,
|
|
@@ -599,34 +586,6 @@ KeyListener,
|
|
|
599
586
|
|
|
600
587
|
|
|
601
588
|
|
|
602
|
-
// Register key event handlers
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
keyDownHandler((keyCode) => {
|
|
607
|
-
|
|
608
|
-
console.log("Key down:", keyCode);
|
|
609
|
-
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
// Key down: 123
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
keyUpHandler((keyCode) => {
|
|
619
|
-
|
|
620
|
-
console.log("Key up:", keyCode);
|
|
621
|
-
|
|
622
|
-
});
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
// Key up: 123
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
589
|
// Retrieve window data
|
|
631
590
|
|
|
632
591
|
|
|
@@ -699,11 +658,11 @@ typeString("Hello, world!", 100); // Type with a delay of 100ms between characte
|
|
|
699
658
|
|
|
700
659
|
|
|
701
660
|
|
|
702
|
-
// Use
|
|
661
|
+
// Use KeyboardListener class
|
|
703
662
|
|
|
704
663
|
|
|
705
664
|
|
|
706
|
-
const listener =
|
|
665
|
+
const listener = KeyboardListener.listener();
|
|
707
666
|
|
|
708
667
|
|
|
709
668
|
|
|
@@ -734,18 +693,6 @@ console.log("Key up:", data.keyCode, data.keyName);
|
|
|
734
693
|
|
|
735
694
|
```
|
|
736
695
|
|
|
737
|
-
# TODO
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
- Write proper tests
|
|
742
|
-
|
|
743
|
-
- Add more useful functions
|
|
744
|
-
|
|
745
|
-
- Fix issue with Windows scale for font,text,apps
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
696
|
[OpenCV License](https://github.com/opencv/opencv/blob/master/LICENSE)
|
|
750
697
|
[MIT License](https://github.com/T-Rumibul/node-native-win-utils/blob/main/LICENSE)
|
|
751
698
|
|
package/binding.gyp
CHANGED
|
@@ -17,12 +17,15 @@
|
|
|
17
17
|
"libraries": [
|
|
18
18
|
"dwmapi.lib",
|
|
19
19
|
"windowsapp.lib",
|
|
20
|
+
"-lgdi32",
|
|
21
|
+
"-lgdiplus",
|
|
20
22
|
"<!(node -p \"require('path').resolve('libs/libjpeg-turbo.lib')\")",
|
|
21
23
|
"<!(node -p \"require('path').resolve('libs/libpng.lib')\")",
|
|
22
24
|
"<!(node -p \"require('path').resolve('libs/zlib.lib')\")",
|
|
23
25
|
"<!(node -p \"require('path').resolve('libs/opencv_core470.lib')\")",
|
|
24
26
|
"<!(node -p \"require('path').resolve('libs/opencv_imgcodecs470.lib')\")",
|
|
25
27
|
"<!(node -p \"require('path').resolve('libs/opencv_imgproc470.lib')\")",
|
|
28
|
+
"<!(node -p \"require('path').resolve('libs/tesseract.lib')\")",
|
|
26
29
|
|
|
27
30
|
],
|
|
28
31
|
"conditions": [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const __dirnameLocal: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const __dirnameLocal: string;
|
|
@@ -3,24 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.OpenCV = exports.KeyboardListener = exports.textRecognition = exports.KeyCodeHelper = exports.rawPressKey = exports.typeString = exports.mouseDrag = exports.mouseClick = exports.mouseMove = exports.captureWindowN = exports.getWindowData = void 0;
|
|
7
7
|
exports.captureWindow = captureWindow;
|
|
8
8
|
exports.keyPress = keyPress;
|
|
9
|
-
|
|
9
|
+
exports.captureScreenToFile = captureScreenToFile;
|
|
10
|
+
//@ts-nocheck
|
|
11
|
+
const events_1 = __importDefault(require("events"));
|
|
10
12
|
const path_1 = __importDefault(require("path"));
|
|
11
13
|
const fs_1 = __importDefault(require("fs"));
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
const nodeGypBuild = require("node-gyp-build");
|
|
16
|
+
const keyCodes_cjs_1 = require("./keyCodes.cjs");
|
|
17
|
+
Object.defineProperty(exports, "KeyCodeHelper", { enumerable: true, get: function () { return keyCodes_cjs_1.KeyCodeHelper; } });
|
|
18
|
+
const dirnameLocal_cjs_1 = require("./dirnameLocal.cjs");
|
|
19
|
+
const bindings = nodeGypBuild(path_1.default.resolve(dirnameLocal_cjs_1.__dirnameLocal, ".."));
|
|
20
|
+
const { setKeyDownCallback, setKeyUpCallback, unsetKeyDownCallback, unsetKeyUpCallback, getWindowData, captureWindowN, captureScreenAsync, mouseMove, mouseClick, mouseDrag, typeString, pressKey, imread, imwrite, matchTemplate, blur, bgrToGray, drawRectangle, getRegion, textRecognition } = bindings;
|
|
18
21
|
exports.getWindowData = getWindowData;
|
|
19
22
|
exports.captureWindowN = captureWindowN;
|
|
20
23
|
exports.mouseMove = mouseMove;
|
|
21
24
|
exports.mouseClick = mouseClick;
|
|
22
25
|
exports.mouseDrag = mouseDrag;
|
|
23
26
|
exports.typeString = typeString;
|
|
27
|
+
exports.textRecognition = textRecognition;
|
|
24
28
|
const rawPressKey = pressKey;
|
|
25
29
|
exports.rawPressKey = rawPressKey;
|
|
26
30
|
/**
|
|
@@ -33,25 +37,40 @@ function captureWindow(windowName, path) {
|
|
|
33
37
|
const buffer = captureWindowN(windowName);
|
|
34
38
|
if (!buffer)
|
|
35
39
|
return false;
|
|
36
|
-
fs_1.default.writeFileSync(path, buffer);
|
|
40
|
+
fs_1.default.writeFileSync(path, new Uint8Array(buffer));
|
|
37
41
|
return true;
|
|
38
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Captures a screen and saves it to a file.
|
|
45
|
+
* @param path - The file path to save the captured image.
|
|
46
|
+
* @returns True if the capture and save operation is successful, otherwise false.
|
|
47
|
+
*/
|
|
48
|
+
function captureScreenToFile(path) {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
captureScreenAsync().then((buffer) => {
|
|
51
|
+
fs_1.default.writeFileSync(path, new Uint8Array(buffer));
|
|
52
|
+
resolve(true);
|
|
53
|
+
}).catch((err => {
|
|
54
|
+
reject(err);
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
39
58
|
/**
|
|
40
59
|
* Represents a class to listen to keyboard events.
|
|
41
60
|
* @extends EventEmitter
|
|
42
61
|
*/
|
|
43
|
-
class
|
|
62
|
+
class KeyboardListenerPrivate extends events_1.default {
|
|
44
63
|
constructor() {
|
|
45
64
|
super();
|
|
46
|
-
|
|
47
|
-
const keyName =
|
|
65
|
+
setKeyDownCallback((keyCode) => {
|
|
66
|
+
const keyName = keyCodes_cjs_1.keyCodes.get(keyCode.toString());
|
|
48
67
|
this.emit("keyDown", {
|
|
49
68
|
keyCode,
|
|
50
69
|
keyName,
|
|
51
70
|
});
|
|
52
71
|
});
|
|
53
|
-
|
|
54
|
-
const keyName =
|
|
72
|
+
setKeyUpCallback((keyCode) => {
|
|
73
|
+
const keyName = keyCodes_cjs_1.keyCodes.get(keyCode.toString());
|
|
55
74
|
this.emit("keyUp", {
|
|
56
75
|
keyCode,
|
|
57
76
|
keyName,
|
|
@@ -59,7 +78,20 @@ class KeyListener extends EventEmitter {
|
|
|
59
78
|
});
|
|
60
79
|
}
|
|
61
80
|
}
|
|
62
|
-
|
|
81
|
+
class KeyboardListener {
|
|
82
|
+
static listenerInstance = null;
|
|
83
|
+
static listener() {
|
|
84
|
+
if (!this.listenerInstance)
|
|
85
|
+
this.listenerInstance = new KeyboardListenerPrivate();
|
|
86
|
+
return this.listenerInstance;
|
|
87
|
+
}
|
|
88
|
+
static destroy() {
|
|
89
|
+
this.listenerInstance = null;
|
|
90
|
+
unsetKeyDownCallback();
|
|
91
|
+
unsetKeyUpCallback();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.KeyboardListener = KeyboardListener;
|
|
63
95
|
/**
|
|
64
96
|
* Represents the OpenCV class that provides image processing functionality.
|
|
65
97
|
*/
|
|
@@ -141,7 +173,7 @@ class OpenCV {
|
|
|
141
173
|
const buffer = imwrite(this.imageData);
|
|
142
174
|
if (!buffer)
|
|
143
175
|
return;
|
|
144
|
-
fs_1.default.writeFileSync(path, buffer);
|
|
176
|
+
fs_1.default.writeFileSync(path, new Uint8Array(buffer));
|
|
145
177
|
}
|
|
146
178
|
}
|
|
147
179
|
exports.OpenCV = OpenCV;
|
|
@@ -153,7 +185,7 @@ function keyPress(keyCode, repeat) {
|
|
|
153
185
|
reject('Something went wrong');
|
|
154
186
|
return resolve(true);
|
|
155
187
|
}
|
|
156
|
-
for (let i = 0; i
|
|
188
|
+
for (let i = 0; i <= repeat; i++) {
|
|
157
189
|
let result = rawPressKey(keyCode);
|
|
158
190
|
if (!result)
|
|
159
191
|
reject('Something went wrong');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import EventEmitter
|
|
2
|
-
import { KeyCodeHelper } from "./keyCodes";
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
import { KeyCodeHelper } from "./keyCodes.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Represents the data of a window.
|
|
5
5
|
*/
|
|
@@ -35,15 +35,15 @@ export type MatchData = {
|
|
|
35
35
|
export type GetWindowData = (windowName: string) => WindowData;
|
|
36
36
|
export type CaptureWindow = (windowName: string) => Buffer;
|
|
37
37
|
/**
|
|
38
|
-
* The handler to listen to key-
|
|
38
|
+
* The handler to listen to key-events.
|
|
39
39
|
* @param callback - The callback function to handle key-down events.
|
|
40
40
|
*/
|
|
41
|
-
export type
|
|
41
|
+
export type SetKeyCallback = (callback: (keyCode: number) => void) => void;
|
|
42
42
|
/**
|
|
43
|
-
* The handler to
|
|
44
|
-
* @param callback - The callback function to handle key-
|
|
43
|
+
* The handler to stop thread listening to key-events.
|
|
44
|
+
* @param callback - The callback function to handle key-down events.
|
|
45
45
|
*/
|
|
46
|
-
export type
|
|
46
|
+
export type UnsetKeyCallback = () => void;
|
|
47
47
|
/**
|
|
48
48
|
* Function type for moving the mouse.
|
|
49
49
|
*/
|
|
@@ -80,7 +80,9 @@ export type Blur = (image: ImageData, sizeX: number, sizeY: number) => ImageData
|
|
|
80
80
|
export type BgrToGray = (image: ImageData) => ImageData;
|
|
81
81
|
export type DrawRectangle = (image: ImageData, start: Point, end: Point, rgb: Color, thickness: number) => ImageData;
|
|
82
82
|
export type GetRegion = (image: ImageData, region: ROI) => ImageData;
|
|
83
|
-
|
|
83
|
+
export type TextRecognition = (trainedDataPath: string, dataLang: string, imagePath: string) => string;
|
|
84
|
+
export type CaptureScreenAsync = () => Promise<Buffer>;
|
|
85
|
+
declare const getWindowData: GetWindowData, captureWindowN: CaptureWindow, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString, textRecognition: TextRecognition;
|
|
84
86
|
declare const rawPressKey: PressKey;
|
|
85
87
|
/**
|
|
86
88
|
* Captures a window and saves it to a file.
|
|
@@ -89,7 +91,13 @@ declare const rawPressKey: PressKey;
|
|
|
89
91
|
* @returns True if the capture and save operation is successful, otherwise false.
|
|
90
92
|
*/
|
|
91
93
|
declare function captureWindow(windowName: string, path: string): boolean;
|
|
92
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Captures a screen and saves it to a file.
|
|
96
|
+
* @param path - The file path to save the captured image.
|
|
97
|
+
* @returns True if the capture and save operation is successful, otherwise false.
|
|
98
|
+
*/
|
|
99
|
+
declare function captureScreenToFile(path: string): Promise<boolean>;
|
|
100
|
+
interface KeyboardListenerPrivate extends EventEmitter {
|
|
93
101
|
/**
|
|
94
102
|
* Event: Fires when a key is pressed down.
|
|
95
103
|
* @param event - The event name ('keyDown').
|
|
@@ -113,13 +121,18 @@ export interface KeyListener extends EventEmitter {
|
|
|
113
121
|
* Represents a class to listen to keyboard events.
|
|
114
122
|
* @extends EventEmitter
|
|
115
123
|
*/
|
|
116
|
-
|
|
124
|
+
declare class KeyboardListenerPrivate extends EventEmitter {
|
|
117
125
|
constructor();
|
|
118
126
|
}
|
|
127
|
+
declare class KeyboardListener {
|
|
128
|
+
private static listenerInstance;
|
|
129
|
+
static listener(): KeyboardListenerPrivate;
|
|
130
|
+
static destroy(): void;
|
|
131
|
+
}
|
|
119
132
|
/**
|
|
120
133
|
* Represents the OpenCV class that provides image processing functionality.
|
|
121
134
|
*/
|
|
122
|
-
|
|
135
|
+
declare class OpenCV {
|
|
123
136
|
imageData: ImageData;
|
|
124
137
|
/**
|
|
125
138
|
* Represents the OpenCV class that provides image processing functionality.
|
|
@@ -175,4 +188,4 @@ export declare class OpenCV {
|
|
|
175
188
|
imwrite(path: string): void;
|
|
176
189
|
}
|
|
177
190
|
declare function keyPress(keyCode: number, repeat?: number): Promise<boolean>;
|
|
178
|
-
export {
|
|
191
|
+
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, KeyboardListener, OpenCV };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
import { KeyCodeHelper } from "./keyCodes.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Represents the data of a window.
|
|
5
|
+
*/
|
|
6
|
+
export type WindowData = {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Represents the data of an image.
|
|
14
|
+
*/
|
|
15
|
+
export type ImageData = {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
data: Uint8Array;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Represents the result of a template matching operation.
|
|
22
|
+
*/
|
|
23
|
+
export type MatchData = {
|
|
24
|
+
minValue: number;
|
|
25
|
+
maxValue: number;
|
|
26
|
+
minLocation: {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
};
|
|
30
|
+
maxLocation: {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type GetWindowData = (windowName: string) => WindowData;
|
|
36
|
+
export type CaptureWindow = (windowName: string) => Buffer;
|
|
37
|
+
/**
|
|
38
|
+
* The handler to listen to key-events.
|
|
39
|
+
* @param callback - The callback function to handle key-down events.
|
|
40
|
+
*/
|
|
41
|
+
export type SetKeyCallback = (callback: (keyCode: number) => void) => void;
|
|
42
|
+
/**
|
|
43
|
+
* The handler to stop thread listening to key-events.
|
|
44
|
+
* @param callback - The callback function to handle key-down events.
|
|
45
|
+
*/
|
|
46
|
+
export type UnsetKeyCallback = () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Function type for moving the mouse.
|
|
49
|
+
*/
|
|
50
|
+
export type MouseMove = (posX: number, posY: number) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Function type for simulating a mouse click.
|
|
53
|
+
*/
|
|
54
|
+
export type MouseClick = (button?: "left" | "middle" | "right") => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Function type for simulating typing.
|
|
57
|
+
*/
|
|
58
|
+
export type TypeString = (stringToType: string, delay?: number) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Function type for simulating key press and release.
|
|
61
|
+
*/
|
|
62
|
+
export type PressKey = (keyCode: number) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Function type for simulating a mouse drag operation.
|
|
65
|
+
*/
|
|
66
|
+
export type MouseDrag = (starX: number, startY: number, endX: Number, endY: number, speed?: number) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Represents a point in a two-dimensional space.
|
|
69
|
+
*/
|
|
70
|
+
export type Point = [x: number, y: number];
|
|
71
|
+
export type Color = [r: number, g: number, b: number];
|
|
72
|
+
/**
|
|
73
|
+
* Represents a region of interest in an image.
|
|
74
|
+
*/
|
|
75
|
+
export type ROI = [x: number, y: number, width: number, height: number];
|
|
76
|
+
export type Imread = (path: string) => ImageData;
|
|
77
|
+
export type Imwrite = (image: ImageData) => Buffer;
|
|
78
|
+
export type MatchTemplate = (image: ImageData, template: ImageData, method?: number | null, mask?: ImageData) => MatchData;
|
|
79
|
+
export type Blur = (image: ImageData, sizeX: number, sizeY: number) => ImageData;
|
|
80
|
+
export type BgrToGray = (image: ImageData) => ImageData;
|
|
81
|
+
export type DrawRectangle = (image: ImageData, start: Point, end: Point, rgb: Color, thickness: number) => ImageData;
|
|
82
|
+
export type GetRegion = (image: ImageData, region: ROI) => ImageData;
|
|
83
|
+
export type TextRecognition = (trainedDataPath: string, dataLang: string, imagePath: string) => string;
|
|
84
|
+
export type CaptureScreenAsync = () => Promise<Buffer>;
|
|
85
|
+
declare const getWindowData: GetWindowData, captureWindowN: CaptureWindow, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString, textRecognition: TextRecognition;
|
|
86
|
+
declare const rawPressKey: PressKey;
|
|
87
|
+
/**
|
|
88
|
+
* Captures a window and saves it to a file.
|
|
89
|
+
* @param windowName - The name of the window to capture.
|
|
90
|
+
* @param path - The file path to save the captured image.
|
|
91
|
+
* @returns True if the capture and save operation is successful, otherwise false.
|
|
92
|
+
*/
|
|
93
|
+
declare function captureWindow(windowName: string, path: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Captures a screen and saves it to a file.
|
|
96
|
+
* @param path - The file path to save the captured image.
|
|
97
|
+
* @returns True if the capture and save operation is successful, otherwise false.
|
|
98
|
+
*/
|
|
99
|
+
declare function captureScreenToFile(path: string): Promise<boolean>;
|
|
100
|
+
interface KeyboardListenerPrivate extends EventEmitter {
|
|
101
|
+
/**
|
|
102
|
+
* Event: Fires when a key is pressed down.
|
|
103
|
+
* @param event - The event name ('keyDown').
|
|
104
|
+
* @param callback - The callback function to handle the event.
|
|
105
|
+
*/
|
|
106
|
+
on(event: "keyDown", callback: (data: {
|
|
107
|
+
keyCode: number;
|
|
108
|
+
keyName: string;
|
|
109
|
+
}) => void): this;
|
|
110
|
+
/**
|
|
111
|
+
* Event: Fires when a key is released.
|
|
112
|
+
* @param event - The event name ('keyUp').
|
|
113
|
+
* @param callback - The callback function to handle the event.
|
|
114
|
+
*/
|
|
115
|
+
on(event: "keyUp", callback: (data: {
|
|
116
|
+
keyCode: number;
|
|
117
|
+
keyName: string;
|
|
118
|
+
}) => void): this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Represents a class to listen to keyboard events.
|
|
122
|
+
* @extends EventEmitter
|
|
123
|
+
*/
|
|
124
|
+
declare class KeyboardListenerPrivate extends EventEmitter {
|
|
125
|
+
constructor();
|
|
126
|
+
}
|
|
127
|
+
declare class KeyboardListener {
|
|
128
|
+
private static listenerInstance;
|
|
129
|
+
static listener(): KeyboardListenerPrivate;
|
|
130
|
+
static destroy(): void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Represents the OpenCV class that provides image processing functionality.
|
|
134
|
+
*/
|
|
135
|
+
declare class OpenCV {
|
|
136
|
+
imageData: ImageData;
|
|
137
|
+
/**
|
|
138
|
+
* Represents the OpenCV class that provides image processing functionality.
|
|
139
|
+
*/
|
|
140
|
+
constructor(image: string | ImageData);
|
|
141
|
+
/**
|
|
142
|
+
* The width of the image.
|
|
143
|
+
*/
|
|
144
|
+
get width(): number;
|
|
145
|
+
/**
|
|
146
|
+
* The height of the image.
|
|
147
|
+
*/
|
|
148
|
+
get height(): number;
|
|
149
|
+
/**
|
|
150
|
+
* Matches a template image within the current image.
|
|
151
|
+
* @param template - The template image data to search for.
|
|
152
|
+
* @param method - The template matching method (optional).
|
|
153
|
+
* @param mask - The optional mask image data to apply the operation (optional).
|
|
154
|
+
* @returns The result of the template matching operation.
|
|
155
|
+
*/
|
|
156
|
+
matchTemplate(template: ImageData, method?: number | null, mask?: ImageData): MatchData;
|
|
157
|
+
/**
|
|
158
|
+
* Applies a blur filter to the image.
|
|
159
|
+
* @param sizeX - The horizontal size of the blur filter.
|
|
160
|
+
* @param sizeY - The vertical size of the blur filter.
|
|
161
|
+
* @returns A new OpenCV instance with the blurred image data.
|
|
162
|
+
*/
|
|
163
|
+
blur(sizeX: number, sizeY: number): OpenCV;
|
|
164
|
+
/**
|
|
165
|
+
* Converts the image from BGR to grayscale.
|
|
166
|
+
* @returns A new OpenCV instance with the grayscale image data.
|
|
167
|
+
*/
|
|
168
|
+
bgrToGray(): OpenCV;
|
|
169
|
+
/**
|
|
170
|
+
* Draws a rectangle on the image.
|
|
171
|
+
* @param start - The starting point of the rectangle.
|
|
172
|
+
* @param end - The ending point of the rectangle.
|
|
173
|
+
* @param rgb - The color (RGB) of the rectangle.
|
|
174
|
+
* @param thickness - The thickness of the rectangle's border.
|
|
175
|
+
* @returns A new OpenCV instance with the image containing the drawn rectangle.
|
|
176
|
+
*/
|
|
177
|
+
drawRectangle(start: Point, end: Point, rgb: Color, thickness: number): OpenCV;
|
|
178
|
+
/**
|
|
179
|
+
* Extracts a region of interest (ROI) from the image.
|
|
180
|
+
* @param region - The region of interest defined as [x, y, width, height].
|
|
181
|
+
* @returns A new OpenCV instance with the extracted region of interest.
|
|
182
|
+
*/
|
|
183
|
+
getRegion(region: ROI): OpenCV;
|
|
184
|
+
/**
|
|
185
|
+
* Writes the image data to a file.
|
|
186
|
+
* @param path - The file path to save the image.
|
|
187
|
+
*/
|
|
188
|
+
imwrite(path: string): void;
|
|
189
|
+
}
|
|
190
|
+
declare function keyPress(keyCode: number, repeat?: number): Promise<boolean>;
|
|
191
|
+
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, KeyboardListener, OpenCV };
|