@aspiresys/visor 1.2.9 → 1.2.10
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/dist/index.d.ts +123 -5
- package/dist/index.js +128 -0
- package/inspector/index.html +1 -1
- package/inspector/src/renderer.js +3 -0
- package/package.json +1 -1
- package/inspector/templates/template.png +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Key, Button, Point } from "@nut-tree-fork/nut-js";
|
|
2
|
+
import { Region } from "./types";
|
|
2
3
|
export declare class Visor {
|
|
3
4
|
mouse: import("@nut-tree-fork/nut-js").MouseClass;
|
|
4
5
|
keyboard: import("@nut-tree-fork/nut-js").KeyboardClass;
|
|
@@ -6,6 +7,123 @@ export declare class Visor {
|
|
|
6
7
|
Button: typeof Button;
|
|
7
8
|
private configWarningShown;
|
|
8
9
|
private checkConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Moves the mouse cursor to the
|
|
12
|
+
* center of a specific screen region.
|
|
13
|
+
*
|
|
14
|
+
* Region coordinates typically come from:
|
|
15
|
+
* - visor.find()
|
|
16
|
+
* - visor.findAll()
|
|
17
|
+
* - OCR text matching
|
|
18
|
+
* - Visor Inspector
|
|
19
|
+
*
|
|
20
|
+
* Display scaling is automatically
|
|
21
|
+
* applied using the configured
|
|
22
|
+
* scale factor.
|
|
23
|
+
*
|
|
24
|
+
* @param region Screen region coordinates.
|
|
25
|
+
* @param offset Offset coords.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* await visor.moveToRegion({
|
|
29
|
+
* x: 100,
|
|
30
|
+
* y: 200,
|
|
31
|
+
* width: 150,
|
|
32
|
+
* height: 50
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
35
|
+
moveToRegion(region: Region, offset?: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Performs a left mouse click at the
|
|
41
|
+
* center of a specific screen region.
|
|
42
|
+
*
|
|
43
|
+
* Region coordinates typically come from:
|
|
44
|
+
* - visor.find()
|
|
45
|
+
* - visor.findAll()
|
|
46
|
+
* - OCR text matching
|
|
47
|
+
* - Visor Inspector
|
|
48
|
+
*
|
|
49
|
+
* Display scaling is automatically
|
|
50
|
+
* applied using the configured
|
|
51
|
+
* scale factor.
|
|
52
|
+
*
|
|
53
|
+
* @param region Screen region coordinates.
|
|
54
|
+
* @param offset Offset coords.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* await visor.clickRegion({
|
|
58
|
+
* x: 100,
|
|
59
|
+
* y: 200,
|
|
60
|
+
* width: 150,
|
|
61
|
+
* height: 50
|
|
62
|
+
* });
|
|
63
|
+
*/
|
|
64
|
+
clickRegion(region: Region, offset?: {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
}): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Performs a double left mouse click
|
|
70
|
+
* at the center of a specific
|
|
71
|
+
* screen region.
|
|
72
|
+
*
|
|
73
|
+
* Region coordinates typically come from:
|
|
74
|
+
* - visor.find()
|
|
75
|
+
* - visor.findAll()
|
|
76
|
+
* - OCR text matching
|
|
77
|
+
* - Visor Inspector
|
|
78
|
+
*
|
|
79
|
+
* Display scaling is automatically
|
|
80
|
+
* applied using the configured
|
|
81
|
+
* scale factor.
|
|
82
|
+
*
|
|
83
|
+
* @param region Screen region coordinates.
|
|
84
|
+
* @param offset Offset coords.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* await visor.doubleClickRegion({
|
|
88
|
+
* x: 100,
|
|
89
|
+
* y: 200,
|
|
90
|
+
* width: 150,
|
|
91
|
+
* height: 50
|
|
92
|
+
* });
|
|
93
|
+
*/
|
|
94
|
+
doubleClickRegion(region: Region, offset?: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
}): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Performs a right mouse click at the
|
|
100
|
+
* center of a specific screen region.
|
|
101
|
+
*
|
|
102
|
+
* Region coordinates typically come from:
|
|
103
|
+
* - visor.find()
|
|
104
|
+
* - visor.findAll()
|
|
105
|
+
* - OCR text matching
|
|
106
|
+
* - Visor Inspector
|
|
107
|
+
*
|
|
108
|
+
* Display scaling is automatically
|
|
109
|
+
* applied using the configured
|
|
110
|
+
* scale factor.
|
|
111
|
+
*
|
|
112
|
+
* @param region Screen region coordinates.
|
|
113
|
+
* @param offset Offset coords.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* await visor.rightClickRegion({
|
|
117
|
+
* x: 100,
|
|
118
|
+
* y: 200,
|
|
119
|
+
* width: 150,
|
|
120
|
+
* height: 50
|
|
121
|
+
* });
|
|
122
|
+
*/
|
|
123
|
+
rightClickRegion(region: Region, offset?: {
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
}): Promise<void>;
|
|
9
127
|
/**
|
|
10
128
|
* Finds an image on screen using OpenCV
|
|
11
129
|
* and performs a left mouse click
|
|
@@ -126,7 +244,7 @@ export declare class Visor {
|
|
|
126
244
|
* const region =
|
|
127
245
|
* await visor.find("save.png");
|
|
128
246
|
*/
|
|
129
|
-
find(image: string, confidence?: number): Promise<
|
|
247
|
+
find(image: string, confidence?: number): Promise<Region>;
|
|
130
248
|
/**
|
|
131
249
|
* Checks whether an image exists
|
|
132
250
|
* on the current screen.
|
|
@@ -169,7 +287,7 @@ export declare class Visor {
|
|
|
169
287
|
* const matches =
|
|
170
288
|
* await visor.findAll("icon.png");
|
|
171
289
|
*/
|
|
172
|
-
findAll(image: string, confidence?: number): Promise<
|
|
290
|
+
findAll(image: string, confidence?: number): Promise<Region[]>;
|
|
173
291
|
/**
|
|
174
292
|
* Finds all image matches and prints
|
|
175
293
|
* a formatted match preview including
|
|
@@ -192,7 +310,7 @@ export declare class Visor {
|
|
|
192
310
|
* @example
|
|
193
311
|
* await visor.previewMatches("button.png");
|
|
194
312
|
*/
|
|
195
|
-
previewMatches(image: string, confidence?: number): Promise<
|
|
313
|
+
previewMatches(image: string, confidence?: number): Promise<Region[]>;
|
|
196
314
|
/**
|
|
197
315
|
* Waits until an image appears
|
|
198
316
|
* on the screen.
|
|
@@ -342,7 +460,7 @@ export declare class Visor {
|
|
|
342
460
|
y: number;
|
|
343
461
|
width: number;
|
|
344
462
|
height: number;
|
|
345
|
-
}): Promise<
|
|
463
|
+
}): Promise<Region>;
|
|
346
464
|
/**
|
|
347
465
|
* Checks whether specific text exists
|
|
348
466
|
* on screen using OCR.
|
|
@@ -783,7 +901,7 @@ export declare class Visor {
|
|
|
783
901
|
*/
|
|
784
902
|
findAny(images: string[], confidence?: number): Promise<{
|
|
785
903
|
image: string;
|
|
786
|
-
region:
|
|
904
|
+
region: Region;
|
|
787
905
|
}>;
|
|
788
906
|
/**
|
|
789
907
|
* Checks whether any image from
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,134 @@ class Visor {
|
|
|
48
48
|
this.configWarningShown = true;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Moves the mouse cursor to the
|
|
53
|
+
* center of a specific screen region.
|
|
54
|
+
*
|
|
55
|
+
* Region coordinates typically come from:
|
|
56
|
+
* - visor.find()
|
|
57
|
+
* - visor.findAll()
|
|
58
|
+
* - OCR text matching
|
|
59
|
+
* - Visor Inspector
|
|
60
|
+
*
|
|
61
|
+
* Display scaling is automatically
|
|
62
|
+
* applied using the configured
|
|
63
|
+
* scale factor.
|
|
64
|
+
*
|
|
65
|
+
* @param region Screen region coordinates.
|
|
66
|
+
* @param offset Offset coords.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* await visor.moveToRegion({
|
|
70
|
+
* x: 100,
|
|
71
|
+
* y: 200,
|
|
72
|
+
* width: 150,
|
|
73
|
+
* height: 50
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
76
|
+
async moveToRegion(region, offset = {
|
|
77
|
+
x: 0,
|
|
78
|
+
y: 0
|
|
79
|
+
}) {
|
|
80
|
+
await (0, mouse_1.moveToRegion)(region, offset);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Performs a left mouse click at the
|
|
84
|
+
* center of a specific screen region.
|
|
85
|
+
*
|
|
86
|
+
* Region coordinates typically come from:
|
|
87
|
+
* - visor.find()
|
|
88
|
+
* - visor.findAll()
|
|
89
|
+
* - OCR text matching
|
|
90
|
+
* - Visor Inspector
|
|
91
|
+
*
|
|
92
|
+
* Display scaling is automatically
|
|
93
|
+
* applied using the configured
|
|
94
|
+
* scale factor.
|
|
95
|
+
*
|
|
96
|
+
* @param region Screen region coordinates.
|
|
97
|
+
* @param offset Offset coords.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* await visor.clickRegion({
|
|
101
|
+
* x: 100,
|
|
102
|
+
* y: 200,
|
|
103
|
+
* width: 150,
|
|
104
|
+
* height: 50
|
|
105
|
+
* });
|
|
106
|
+
*/
|
|
107
|
+
async clickRegion(region, offset = {
|
|
108
|
+
x: 0,
|
|
109
|
+
y: 0
|
|
110
|
+
}) {
|
|
111
|
+
await (0, mouse_1.moveToRegion)(region, offset);
|
|
112
|
+
await this.mouse.click(this.Button.LEFT);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Performs a double left mouse click
|
|
116
|
+
* at the center of a specific
|
|
117
|
+
* screen region.
|
|
118
|
+
*
|
|
119
|
+
* Region coordinates typically come from:
|
|
120
|
+
* - visor.find()
|
|
121
|
+
* - visor.findAll()
|
|
122
|
+
* - OCR text matching
|
|
123
|
+
* - Visor Inspector
|
|
124
|
+
*
|
|
125
|
+
* Display scaling is automatically
|
|
126
|
+
* applied using the configured
|
|
127
|
+
* scale factor.
|
|
128
|
+
*
|
|
129
|
+
* @param region Screen region coordinates.
|
|
130
|
+
* @param offset Offset coords.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* await visor.doubleClickRegion({
|
|
134
|
+
* x: 100,
|
|
135
|
+
* y: 200,
|
|
136
|
+
* width: 150,
|
|
137
|
+
* height: 50
|
|
138
|
+
* });
|
|
139
|
+
*/
|
|
140
|
+
async doubleClickRegion(region, offset = {
|
|
141
|
+
x: 0,
|
|
142
|
+
y: 0
|
|
143
|
+
}) {
|
|
144
|
+
await (0, mouse_1.moveToRegion)(region, offset);
|
|
145
|
+
await this.mouse.doubleClick(this.Button.LEFT);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Performs a right mouse click at the
|
|
149
|
+
* center of a specific screen region.
|
|
150
|
+
*
|
|
151
|
+
* Region coordinates typically come from:
|
|
152
|
+
* - visor.find()
|
|
153
|
+
* - visor.findAll()
|
|
154
|
+
* - OCR text matching
|
|
155
|
+
* - Visor Inspector
|
|
156
|
+
*
|
|
157
|
+
* Display scaling is automatically
|
|
158
|
+
* applied using the configured
|
|
159
|
+
* scale factor.
|
|
160
|
+
*
|
|
161
|
+
* @param region Screen region coordinates.
|
|
162
|
+
* @param offset Offset coords.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* await visor.rightClickRegion({
|
|
166
|
+
* x: 100,
|
|
167
|
+
* y: 200,
|
|
168
|
+
* width: 150,
|
|
169
|
+
* height: 50
|
|
170
|
+
* });
|
|
171
|
+
*/
|
|
172
|
+
async rightClickRegion(region, offset = {
|
|
173
|
+
x: 0,
|
|
174
|
+
y: 0
|
|
175
|
+
}) {
|
|
176
|
+
await (0, mouse_1.moveToRegion)(region, offset);
|
|
177
|
+
await this.mouse.click(this.Button.RIGHT);
|
|
178
|
+
}
|
|
51
179
|
/**
|
|
52
180
|
* Finds an image on screen using OpenCV
|
|
53
181
|
* and performs a left mouse click
|
package/inspector/index.html
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
</section>
|
|
33
33
|
<div class="capture-layout">
|
|
34
34
|
<div class="capture-panel">
|
|
35
|
-
<h3 class="section-title"> Current Capture </h3>
|
|
35
|
+
<h3 class="section-title"> Current Capture (X:<span id="mousex"></span>, Y:<span id="mousey"></span>)</h3>
|
|
36
36
|
<canvas id="screenCanvas" class="canvas"></canvas>
|
|
37
37
|
</div>
|
|
38
38
|
<div class="result-panel">
|
|
@@ -58,6 +58,8 @@ canvas.addEventListener("mousedown",
|
|
|
58
58
|
canvas.addEventListener("mousemove",
|
|
59
59
|
(e) => {
|
|
60
60
|
if (!selecting) {
|
|
61
|
+
document.getElementById("mousex").innerHTML = Math.round(e.offsetX * imageScaleX);
|
|
62
|
+
document.getElementById("mousey").innerHTML = Math.round(e.offsetY * imageScaleY);
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
63
65
|
displayEndX = e.offsetX;
|
|
@@ -95,6 +97,7 @@ canvas.addEventListener("mouseup",
|
|
|
95
97
|
}
|
|
96
98
|
);
|
|
97
99
|
|
|
100
|
+
|
|
98
101
|
saveBtn.addEventListener("click",
|
|
99
102
|
async () => {
|
|
100
103
|
if (
|
package/package.json
CHANGED
|
Binary file
|