@@ -74,6 +74,8 @@ export interface ScreenConfig {
74
74
resourceDirectory : string ;
75
75
}
76
76
77
+ export type FindInput = Image ;
78
+
77
79
/**
78
80
* {@link ScreenClass } class provides methods to access screen content of a systems main display
79
81
*/
@@ -119,11 +121,11 @@ export class ScreenClass {
119
121
120
122
/**
121
123
* {@link find } will search for a single occurrence of a template image on a systems main screen
122
- * @param template Template {@link Image} instance
124
+ * @param searchInput Template {@link Image} instance
123
125
* @param params {@link LocationParameters } which are used to fine tune search region and / or match confidence
124
126
*/
125
127
public async find (
126
- template : Image | Promise < Image > ,
128
+ searchInput : FindInput | Promise < FindInput > ,
127
129
params ?: OptionalSearchParameters
128
130
) : Promise < Region > {
129
131
const {
@@ -134,7 +136,7 @@ export class ScreenClass {
134
136
searchMultipleScales,
135
137
} = await this . getFindParameters ( params ) ;
136
138
137
- const needle = await ScreenClass . getNeedle ( template ) ;
139
+ const needle = await ScreenClass . getNeedle ( searchInput ) ;
138
140
139
141
const matchRequest = new MatchRequest (
140
142
screenImage ,
@@ -236,6 +238,13 @@ export class ScreenClass {
236
238
regionToHighlight : Region | Promise < Region >
237
239
) : Promise < Region > {
238
240
const highlightRegion = await regionToHighlight ;
241
+ if ( ! isRegion ( highlightRegion ) ) {
242
+ throw Error (
243
+ `highlight requires an Region, but received ${ JSON . stringify (
244
+ highlightRegion
245
+ ) } `
246
+ ) ;
247
+ }
239
248
await this . providerRegistry
240
249
. getScreen ( )
241
250
. highlightScreenRegion (
@@ -380,9 +389,15 @@ export class ScreenClass {
380
389
public async grabRegion (
381
390
regionToGrab : Region | Promise < Region >
382
391
) : Promise < Image > {
383
- return this . providerRegistry
384
- . getScreen ( )
385
- . grabScreenRegion ( await regionToGrab ) ;
392
+ const targetRegion = await regionToGrab ;
393
+ if ( ! isRegion ( targetRegion ) ) {
394
+ throw Error (
395
+ `grabRegion requires an Region, but received ${ JSON . stringify (
396
+ targetRegion
397
+ ) } `
398
+ ) ;
399
+ }
400
+ return this . providerRegistry . getScreen ( ) . grabScreenRegion ( targetRegion ) ;
386
401
}
387
402
388
403
/**
0 commit comments