node-native-win-utils 1.3.1 → 1.3.2-alpha.1

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 CHANGED
@@ -1,350 +1,350 @@
1
- [![License][license-src]][license-href]
2
-
3
- # Node Native Win Utils
4
-
5
- I did it for myself because I didn't feel like dealing with libraries like 'node-ffi' to implement this functionality. Maybe someone will find it useful. It's WINDOWS OS ONLY
6
-
7
- This package is a native addon for Node.js that allows you to perform various utility operations on Windows systems. It includes key event listeners, window data retrieval, window screenshot capture functionality, mouse movement, mouse click, mouse drag, and typing functionality, also I included precompiled libs of OpenCV(core, imgcodecs, imgproc)
8
-
9
- # Installation
10
-
11
- You can install the package using npm:
12
-
13
- ```shell
14
-
15
- npm install node-native-win-utils
16
-
17
- ```
18
-
19
- # Usage
20
-
21
- ## Importing the Package
22
-
23
- To use the package, import the necessary functions, types, and classes:
24
-
25
- ```javascript
26
- import {
27
- keyDownHandler,
28
- keyUpHandler,
29
- getWindowData,
30
- captureWindow,
31
- captureWindowN,
32
- mouseMove,
33
- mouseClick,
34
- mouseDrag,
35
- typeString,
36
- OpenCV,
37
- } from "node-native-win-utils";
38
- ```
39
-
40
- ## Key Event Listeners
41
-
42
- The package provides `keyDownHandler` and `keyUpHandler` functions, which allow you to register callbacks for key down and key up events, respectively. The callbacks receive the `keyCode` as a parameter:
43
-
44
- ```javascript
45
- keyDownHandler((keyCode) => {
46
- console.log("Key down:", keyCode);
47
- });
48
-
49
- // Key down: 8
50
-
51
- keyUpHandler((keyCode) => {
52
- console.log("Key up:", keyCode);
53
- });
54
-
55
- // Key up: 8
56
- ```
57
-
58
- ## Window Data
59
-
60
- The `getWindowData` function retrieves information about a specific window identified by its name. It returns an object with properties `width`, `height`, `x`, and `y`, representing the window dimensions and position:
61
-
62
- ```javascript
63
- const windowData = getWindowData("Window Name");
64
-
65
- console.log("Window data:", windowData);
66
-
67
- // Window data: { width: 800, height: 600, x: 50, y: 50 }
68
- ```
69
-
70
- ## Window Capture
71
-
72
- The `captureWindow` function allows you to capture a screenshot of a specific window identified by its name. Provide the window name and the output path as parameters:
73
-
74
- ```javascript
75
- captureWindow("Window Name", "output.png");
76
-
77
- // Output: output.png with a screenshot of the window
78
- ```
79
-
80
- ## Mouse Movement
81
-
82
- The `mouseMove` function allows you to move the mouse to a specific position on the screen. Provide the `posX` and `posY` coordinates as parameters:
83
-
84
- ```javascript
85
- mouseMove(100, 200);
86
- ```
87
-
88
- ## Mouse Click
89
-
90
- The `mouseClick` function allows you to perform a mouse click event. Optionally, you can specify the mouse button as a parameter (`"left"`, `"middle"`, or `"right"`). If no button is specified, a left mouse click is performed by default:
91
-
92
- ```javascript
93
- mouseClick(); // Left mouse click
94
-
95
- mouseClick("right"); // Right mouse click
96
- ```
97
-
98
- ## Mouse Drag
99
-
100
- The `mouseDrag` function allows you to simulate dragging the mouse from one position to another. Provide the starting and ending coordinates (`startX`, `startY`, `endX`, `endY`) as parameters. Optionally, you can specify the speed at which the mouse should be dragged:
101
-
102
- ```javascript
103
- mouseDrag(100, 200, 300, 400);
104
-
105
- mouseDrag(100, 200, 300, 400, 100); // Drag with speed 100
106
- ```
107
-
108
- ## Typing
109
-
110
- The `typeString` function allows you to simulate typing a string of characters. Provide the string to type as the `stringToType` parameter. Optionally, you can specify
111
-
112
- a delay between each character (in milliseconds) using the `delay` parameter:
113
-
114
- ```javascript
115
- typeString("Hello, world!");
116
-
117
- typeString("Hello, world!", 100); // Type with a delay of 100ms between characters
118
- ```
119
-
120
- ## Key Listener Class
121
-
122
- The `KeyListener` class extends the EventEmitter class and simplifies working with the `keyDownHandler` and `keyUpHandler` functions. You can register event listeners for the "keyDown" and "keyUp" events using the `on` method:
123
-
124
- ```javascript
125
- const listener = new KeyListener();
126
-
127
- listener.on("keyDown", (data) => {
128
- console.log("Key down:", data.keyCode, data.keyName);
129
- });
130
-
131
- // Key down: 8 Backspace
132
-
133
- listener.on("keyUp", (data) => {
134
- console.log("Key up:", data.keyCode, data.keyName);
135
- });
136
-
137
- // Key up: 8 Backspace
138
- ```
139
-
140
- ## OpenCV
141
-
142
- The `OpenCV` class extends the capabilities of the native addon package by providing various image processing functionalities. It allows users to perform operations such as matching templates, blurring images, converting color formats, drawing rectangles, getting image regions, and writing images to files.
143
-
144
- #### Constructor
145
-
146
- ```typescript
147
- const image = new OpenCV(image: string | ImageData)
148
- ```
149
-
150
- Creates a new instance of the `OpenCV` class with the specified image data. The `image` parameter can be either a file path (string) or an existing `ImageData` object.
151
-
152
- #### Properties
153
-
154
- ##### `imageData: ImageData`
155
-
156
- Holds the underlying image data that will be used for image processing operations.
157
-
158
- ##### `width: number`
159
-
160
- Read-only property that returns the width of the image in pixels.
161
-
162
- ##### `height: number`
163
-
164
- Read-only property that returns the height of the image in pixels.
165
-
166
- #### Methods
167
-
168
- ##### `matchTemplate(template: ImageData, method?: number | null, mask?: ImageData): OpenCV`
169
-
170
- Matches a template image with the current image and returns a new `OpenCV` instance containing the result.
171
-
172
- - `template: ImageData`: The template image data to be matched.
173
- - `method?: number | null`: (Optional) The matching method to be used. If not provided, the default method will be used.(currently no implemented)
174
- - `mask?: ImageData`: (Optional) An optional mask image data to be used during the matching process.
175
-
176
- ##### `blur(sizeX: number, sizeY: number): OpenCV`
177
-
178
- Applies a blur filter to the current image and returns a new `OpenCV` instance containing the blurred result.
179
-
180
- - `sizeX: number`: The size of the blur kernel in the X direction.
181
- - `sizeY: number`: The size of the blur kernel in the Y direction.
182
-
183
- ##### `bgrToGray(): OpenCV`
184
-
185
- Converts the current image from the BGR color format to grayscale and returns a new `OpenCV` instance containing the grayscale result.
186
-
187
- ##### `drawRectangle(start: Point, end: Point, rgb: Color, thickness: number): OpenCV`
188
-
189
- Draws a rectangle on the current image and returns a new `OpenCV` instance containing the modified result.
190
-
191
- - `start: Point`: The starting point (top-left) of the rectangle.
192
- - `end: Point`: The ending point (bottom-right) of the rectangle.
193
- - `rgb: Color`: The color of the rectangle in the RGB format (e.g., `{ r: 255, g: 0, b: 0 }` for red).
194
- - `thickness: number`: The thickness of the rectangle's border.
195
-
196
- ##### `getRegion(region: ROI): OpenCV`
197
-
198
- Extracts a region of interest (ROI) from the current image and returns a new `OpenCV` instance containing the extracted region.
199
-
200
- - `region: ROI`: An object specifying the region of interest with properties `x`, `y`, `width`, `height`.
201
-
202
- ##### `imwrite(path: string): void`
203
-
204
- Writes the current image to a file specified by the `path`.
205
-
206
- - `path: string`: The file path where the image will be saved.
207
-
208
- ## Functions
209
-
210
- | Function | Parameters | Return Type |
211
- | -------------- | ---------------------------------------------------------------------------- | ------------ |
212
- | keyDownHandler | `callback: (keyCode: number) => void` | `void` |
213
- | keyUpHandler | `callback: (keyCode: number) => void` | `void` |
214
- | getWindowData | `windowName: string` | `WindowData` |
215
- | captureWindow | `windowName: string, outputPath: string` | `void` |
216
- | mouseMove | `posX: number, posY: number` | `boolean` |
217
- | mouseClick | `button?: "left" \| "middle" \| "right"` | `boolean` |
218
- | mouseDrag | `startX: number, startY: number, endX: number, endY: number, speed?: number` | `boolean` |
219
- | typeString | `stringToType: string, delay?: number` | `boolean` |
220
- | captureWindowN | `windowName: string` | `Buffer` |
221
-
222
- ## Examples
223
-
224
- Here are some examples of using the package:
225
-
226
- ```javascript
227
- // Example usage of the OpenCV class
228
- import { OpenCV } from "node-native-win-utils";
229
-
230
- const image = new OpenCV("path/to/image.png");
231
-
232
- const template = new OpenCV("path/to/template.png");
233
- const matchedImage = image.matchTemplate(template.imageData);
234
-
235
- const blurredImage = image.blur(5, 5);
236
-
237
- const grayscaleImage = image.bgrToGray();
238
-
239
- const regionOfInterest = { x: 100, y: 100, width: 200, height: 150 };
240
- const regionImage = image.getRegion(regionOfInterest);
241
-
242
- const redColor = { r: 255, g: 0, b: 0 };
243
- const thickRectangle = image.drawRectangle(
244
- { x: 50, y: 50 },
245
- { x: 150, y: 150 },
246
- redColor,
247
- 3
248
- );
249
-
250
- matchedImage.imwrite("output/matched.png");
251
- blurredImage.imwrite("output/blurred.png");
252
- grayscaleImage.imwrite("output/grayscale.png");
253
- regionImage.imwrite("output/region.png");
254
- thickRectangle.imwrite("output/thick_rectangle.png");
255
- ```
256
-
257
- ```javascript
258
- // If you want to aply blur and convert to gray then do it that order:
259
- image.blur(5, 5).bgrToGray();
260
- // Otherwise you will get an error.
261
- ```
262
-
263
- Please note that the above example demonstrates the usage of different methods available in the `OpenCV` class. Make sure to replace `"path/to/image.png"` and `"path/to/template.png"` with actual image file paths.
264
-
265
- ```javascript
266
- import {
267
- keyDownHandler,
268
- keyUpHandler,
269
- getWindowData,
270
- captureWindow,
271
- mouseMove,
272
- mouseClick,
273
- mouseDrag,
274
- typeString,
275
- KeyListener,
276
- } from "node-native-win-utils";
277
-
278
- // Register key event handlers
279
-
280
- keyDownHandler((keyCode) => {
281
- console.log("Key down:", keyCode);
282
- });
283
-
284
- // Key down: 123
285
-
286
- keyUpHandler((keyCode) => {
287
- console.log("Key up:", keyCode);
288
- });
289
-
290
- // Key up: 123
291
-
292
- // Retrieve window data
293
-
294
- const windowData = getWindowData("My Window");
295
-
296
- console.log("Window data:", windowData);
297
-
298
- // Window data: { width: 1024, height: 768, x: 100, y: 100 }
299
-
300
- // Capture window screenshot
301
-
302
- captureWindow("My Window", "output.png");
303
-
304
- // Output: output.png with a screenshot of the window
305
-
306
- // Move the mouse
307
-
308
- mouseMove(100, 200);
309
-
310
- // Perform mouse click
311
-
312
- mouseClick(); // Left mouse click
313
-
314
- mouseClick("right"); // Right mouse click
315
-
316
- // Simulate mouse drag
317
-
318
- mouseDrag(100, 200, 300, 400);
319
-
320
- mouseDrag(100, 200, 300, 400, 100); // Drag with speed 100
321
-
322
- // Simulate typing
323
-
324
- typeString("Hello, world!");
325
-
326
- typeString("Hello, world!", 100); // Type with a delay of 100ms between characters
327
-
328
- // Use KeyListener class
329
-
330
- const listener = new KeyListener();
331
-
332
- listener.on("keyDown", (data) => {
333
- console.log("Key down:", data.keyCode, data.keyName);
334
- });
335
-
336
- // Key down: 8 Backspace
337
-
338
- listener.on("keyUp", (data) => {
339
- console.log("Key up:", data.keyCode, data.keyName);
340
- });
341
-
342
- // Key up: 8 Backspace
343
- ```
344
-
345
- P.S.: As my knowledge of C++ is just brief, most of the C++ code is written with help of GPT-3.5 and GPT-4
346
-
347
- [OpenCV License](https://github.com/opencv/opencv/blob/master/LICENSE)
348
-
349
- [license-src]: https://img.shields.io/github/license/nuxt-modules/icon.svg?style=for-the-badge&colorA=18181B&colorB=28CF8D
350
- [license-href]: https://github.com/RynerNO/node-native-win-utils/blob/main/LICENSE
1
+ [![License][license-src]][license-href]
2
+
3
+ # Node Native Win Utils
4
+
5
+ I did it for myself because I didn't feel like dealing with libraries like 'node-ffi' to implement this functionality. Maybe someone will find it useful. It's WINDOWS OS ONLY
6
+
7
+ This package is a native addon for Node.js that allows you to perform various utility operations on Windows systems. It includes key event listeners, window data retrieval, window screenshot capture functionality, mouse movement, mouse click, mouse drag, and typing functionality, also I included precompiled libs of OpenCV(core, imgcodecs, imgproc)
8
+
9
+ # Installation
10
+
11
+ You can install the package using npm:
12
+
13
+ ```shell
14
+
15
+ npm install node-native-win-utils
16
+
17
+ ```
18
+
19
+ # Usage
20
+
21
+ ## Importing the Package
22
+
23
+ To use the package, import the necessary functions, types, and classes:
24
+
25
+ ```javascript
26
+ import {
27
+ keyDownHandler,
28
+ keyUpHandler,
29
+ getWindowData,
30
+ captureWindow,
31
+ captureWindowN,
32
+ mouseMove,
33
+ mouseClick,
34
+ mouseDrag,
35
+ typeString,
36
+ OpenCV,
37
+ } from "node-native-win-utils";
38
+ ```
39
+
40
+ ## Key Event Listeners
41
+
42
+ The package provides `keyDownHandler` and `keyUpHandler` functions, which allow you to register callbacks for key down and key up events, respectively. The callbacks receive the `keyCode` as a parameter:
43
+
44
+ ```javascript
45
+ keyDownHandler((keyCode) => {
46
+ console.log("Key down:", keyCode);
47
+ });
48
+
49
+ // Key down: 8
50
+
51
+ keyUpHandler((keyCode) => {
52
+ console.log("Key up:", keyCode);
53
+ });
54
+
55
+ // Key up: 8
56
+ ```
57
+
58
+ ## Window Data
59
+
60
+ The `getWindowData` function retrieves information about a specific window identified by its name. It returns an object with properties `width`, `height`, `x`, and `y`, representing the window dimensions and position:
61
+
62
+ ```javascript
63
+ const windowData = getWindowData("Window Name");
64
+
65
+ console.log("Window data:", windowData);
66
+
67
+ // Window data: { width: 800, height: 600, x: 50, y: 50 }
68
+ ```
69
+
70
+ ## Window Capture
71
+
72
+ The `captureWindow` function allows you to capture a screenshot of a specific window identified by its name. Provide the window name and the output path as parameters:
73
+
74
+ ```javascript
75
+ captureWindow("Window Name", "output.png");
76
+
77
+ // Output: output.png with a screenshot of the window
78
+ ```
79
+
80
+ ## Mouse Movement
81
+
82
+ The `mouseMove` function allows you to move the mouse to a specific position on the screen. Provide the `posX` and `posY` coordinates as parameters:
83
+
84
+ ```javascript
85
+ mouseMove(100, 200);
86
+ ```
87
+
88
+ ## Mouse Click
89
+
90
+ The `mouseClick` function allows you to perform a mouse click event. Optionally, you can specify the mouse button as a parameter (`"left"`, `"middle"`, or `"right"`). If no button is specified, a left mouse click is performed by default:
91
+
92
+ ```javascript
93
+ mouseClick(); // Left mouse click
94
+
95
+ mouseClick("right"); // Right mouse click
96
+ ```
97
+
98
+ ## Mouse Drag
99
+
100
+ The `mouseDrag` function allows you to simulate dragging the mouse from one position to another. Provide the starting and ending coordinates (`startX`, `startY`, `endX`, `endY`) as parameters. Optionally, you can specify the speed at which the mouse should be dragged:
101
+
102
+ ```javascript
103
+ mouseDrag(100, 200, 300, 400);
104
+
105
+ mouseDrag(100, 200, 300, 400, 100); // Drag with speed 100
106
+ ```
107
+
108
+ ## Typing
109
+
110
+ The `typeString` function allows you to simulate typing a string of characters. Provide the string to type as the `stringToType` parameter. Optionally, you can specify
111
+
112
+ a delay between each character (in milliseconds) using the `delay` parameter:
113
+
114
+ ```javascript
115
+ typeString("Hello, world!");
116
+
117
+ typeString("Hello, world!", 100); // Type with a delay of 100ms between characters
118
+ ```
119
+
120
+ ## Key Listener Class
121
+
122
+ The `KeyListener` class extends the EventEmitter class and simplifies working with the `keyDownHandler` and `keyUpHandler` functions. You can register event listeners for the "keyDown" and "keyUp" events using the `on` method:
123
+
124
+ ```javascript
125
+ const listener = new KeyListener();
126
+
127
+ listener.on("keyDown", (data) => {
128
+ console.log("Key down:", data.keyCode, data.keyName);
129
+ });
130
+
131
+ // Key down: 8 Backspace
132
+
133
+ listener.on("keyUp", (data) => {
134
+ console.log("Key up:", data.keyCode, data.keyName);
135
+ });
136
+
137
+ // Key up: 8 Backspace
138
+ ```
139
+
140
+ ## OpenCV
141
+
142
+ The `OpenCV` class extends the capabilities of the native addon package by providing various image processing functionalities. It allows users to perform operations such as matching templates, blurring images, converting color formats, drawing rectangles, getting image regions, and writing images to files.
143
+
144
+ #### Constructor
145
+
146
+ ```typescript
147
+ const image = new OpenCV(image: string | ImageData)
148
+ ```
149
+
150
+ Creates a new instance of the `OpenCV` class with the specified image data. The `image` parameter can be either a file path (string) or an existing `ImageData` object.
151
+
152
+ #### Properties
153
+
154
+ ##### `imageData: ImageData`
155
+
156
+ Holds the underlying image data that will be used for image processing operations.
157
+
158
+ ##### `width: number`
159
+
160
+ Read-only property that returns the width of the image in pixels.
161
+
162
+ ##### `height: number`
163
+
164
+ Read-only property that returns the height of the image in pixels.
165
+
166
+ #### Methods
167
+
168
+ ##### `matchTemplate(template: ImageData, method?: number | null, mask?: ImageData): OpenCV`
169
+
170
+ Matches a template image with the current image and returns a new `OpenCV` instance containing the result.
171
+
172
+ - `template: ImageData`: The template image data to be matched.
173
+ - `method?: number | null`: (Optional) The matching method to be used. If not provided, the default method will be used.(currently no implemented)
174
+ - `mask?: ImageData`: (Optional) An optional mask image data to be used during the matching process.
175
+
176
+ ##### `blur(sizeX: number, sizeY: number): OpenCV`
177
+
178
+ Applies a blur filter to the current image and returns a new `OpenCV` instance containing the blurred result.
179
+
180
+ - `sizeX: number`: The size of the blur kernel in the X direction.
181
+ - `sizeY: number`: The size of the blur kernel in the Y direction.
182
+
183
+ ##### `bgrToGray(): OpenCV`
184
+
185
+ Converts the current image from the BGR color format to grayscale and returns a new `OpenCV` instance containing the grayscale result.
186
+
187
+ ##### `drawRectangle(start: Point, end: Point, rgb: Color, thickness: number): OpenCV`
188
+
189
+ Draws a rectangle on the current image and returns a new `OpenCV` instance containing the modified result.
190
+
191
+ - `start: Point`: The starting point (top-left) of the rectangle.
192
+ - `end: Point`: The ending point (bottom-right) of the rectangle.
193
+ - `rgb: Color`: The color of the rectangle in the RGB format (e.g., `{ r: 255, g: 0, b: 0 }` for red).
194
+ - `thickness: number`: The thickness of the rectangle's border.
195
+
196
+ ##### `getRegion(region: ROI): OpenCV`
197
+
198
+ Extracts a region of interest (ROI) from the current image and returns a new `OpenCV` instance containing the extracted region.
199
+
200
+ - `region: ROI`: An object specifying the region of interest with properties `x`, `y`, `width`, `height`.
201
+
202
+ ##### `imwrite(path: string): void`
203
+
204
+ Writes the current image to a file specified by the `path`.
205
+
206
+ - `path: string`: The file path where the image will be saved.
207
+
208
+ ## Functions
209
+
210
+ | Function | Parameters | Return Type |
211
+ | -------------- | ---------------------------------------------------------------------------- | ------------ |
212
+ | keyDownHandler | `callback: (keyCode: number) => void` | `void` |
213
+ | keyUpHandler | `callback: (keyCode: number) => void` | `void` |
214
+ | getWindowData | `windowName: string` | `WindowData` |
215
+ | captureWindow | `windowName: string, outputPath: string` | `void` |
216
+ | mouseMove | `posX: number, posY: number` | `boolean` |
217
+ | mouseClick | `button?: "left" \| "middle" \| "right"` | `boolean` |
218
+ | mouseDrag | `startX: number, startY: number, endX: number, endY: number, speed?: number` | `boolean` |
219
+ | typeString | `stringToType: string, delay?: number` | `boolean` |
220
+ | captureWindowN | `windowName: string` | `Buffer` |
221
+
222
+ ## Examples
223
+
224
+ Here are some examples of using the package:
225
+
226
+ ```javascript
227
+ // Example usage of the OpenCV class
228
+ import { OpenCV } from "node-native-win-utils";
229
+
230
+ const image = new OpenCV("path/to/image.png");
231
+
232
+ const template = new OpenCV("path/to/template.png");
233
+ const matchedImage = image.matchTemplate(template.imageData);
234
+
235
+ const blurredImage = image.blur(5, 5);
236
+
237
+ const grayscaleImage = image.bgrToGray();
238
+
239
+ const regionOfInterest = { x: 100, y: 100, width: 200, height: 150 };
240
+ const regionImage = image.getRegion(regionOfInterest);
241
+
242
+ const redColor = { r: 255, g: 0, b: 0 };
243
+ const thickRectangle = image.drawRectangle(
244
+ { x: 50, y: 50 },
245
+ { x: 150, y: 150 },
246
+ redColor,
247
+ 3
248
+ );
249
+
250
+ matchedImage.imwrite("output/matched.png");
251
+ blurredImage.imwrite("output/blurred.png");
252
+ grayscaleImage.imwrite("output/grayscale.png");
253
+ regionImage.imwrite("output/region.png");
254
+ thickRectangle.imwrite("output/thick_rectangle.png");
255
+ ```
256
+
257
+ ```javascript
258
+ // If you want to aply blur and convert to gray then do it that order:
259
+ image.blur(5, 5).bgrToGray();
260
+ // Otherwise you will get an error.
261
+ ```
262
+
263
+ Please note that the above example demonstrates the usage of different methods available in the `OpenCV` class. Make sure to replace `"path/to/image.png"` and `"path/to/template.png"` with actual image file paths.
264
+
265
+ ```javascript
266
+ import {
267
+ keyDownHandler,
268
+ keyUpHandler,
269
+ getWindowData,
270
+ captureWindow,
271
+ mouseMove,
272
+ mouseClick,
273
+ mouseDrag,
274
+ typeString,
275
+ KeyListener,
276
+ } from "node-native-win-utils";
277
+
278
+ // Register key event handlers
279
+
280
+ keyDownHandler((keyCode) => {
281
+ console.log("Key down:", keyCode);
282
+ });
283
+
284
+ // Key down: 123
285
+
286
+ keyUpHandler((keyCode) => {
287
+ console.log("Key up:", keyCode);
288
+ });
289
+
290
+ // Key up: 123
291
+
292
+ // Retrieve window data
293
+
294
+ const windowData = getWindowData("My Window");
295
+
296
+ console.log("Window data:", windowData);
297
+
298
+ // Window data: { width: 1024, height: 768, x: 100, y: 100 }
299
+
300
+ // Capture window screenshot
301
+
302
+ captureWindow("My Window", "output.png");
303
+
304
+ // Output: output.png with a screenshot of the window
305
+
306
+ // Move the mouse
307
+
308
+ mouseMove(100, 200);
309
+
310
+ // Perform mouse click
311
+
312
+ mouseClick(); // Left mouse click
313
+
314
+ mouseClick("right"); // Right mouse click
315
+
316
+ // Simulate mouse drag
317
+
318
+ mouseDrag(100, 200, 300, 400);
319
+
320
+ mouseDrag(100, 200, 300, 400, 100); // Drag with speed 100
321
+
322
+ // Simulate typing
323
+
324
+ typeString("Hello, world!");
325
+
326
+ typeString("Hello, world!", 100); // Type with a delay of 100ms between characters
327
+
328
+ // Use KeyListener class
329
+
330
+ const listener = new KeyListener();
331
+
332
+ listener.on("keyDown", (data) => {
333
+ console.log("Key down:", data.keyCode, data.keyName);
334
+ });
335
+
336
+ // Key down: 8 Backspace
337
+
338
+ listener.on("keyUp", (data) => {
339
+ console.log("Key up:", data.keyCode, data.keyName);
340
+ });
341
+
342
+ // Key up: 8 Backspace
343
+ ```
344
+
345
+ P.S.: As my knowledge of C++ is just brief, most of the C++ code is written with help of GPT-3.5 and GPT-4
346
+
347
+ [OpenCV License](https://github.com/opencv/opencv/blob/master/LICENSE)
348
+
349
+ [license-src]: https://img.shields.io/github/license/nuxt-modules/icon.svg?style=for-the-badge&colorA=18181B&colorB=28CF8D
350
+ [license-href]: https://github.com/RynerNO/node-native-win-utils/blob/main/LICENSE