Skip to content

Commit d8b183d

Browse files
authored
Merge pull request #284 from nut-tree/feature/278/grab_screen
(#278) Adjusted captureRegion and grabRegion parameters to accept Pro…
2 parents c17b770 + 6de99cb commit d8b183d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/screen.class.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ export class ScreenClass {
226226
*/
227227
public async captureRegion(
228228
fileName: string,
229-
regionToCapture: Region,
229+
regionToCapture: Region | Promise<Region>,
230230
fileFormat: FileType = FileType.PNG,
231231
filePath: string = cwd(),
232232
fileNamePrefix: string = "",
233233
fileNamePostfix: string = ""): Promise<string> {
234-
const regionImage = await this.vision.grabScreenRegion(regionToCapture);
234+
const regionImage = await this.vision.grabScreenRegion(await regionToCapture);
235235
return this.saveImage(
236236
regionImage,
237237
fileName,
@@ -243,9 +243,10 @@ export class ScreenClass {
243243

244244
/**
245245
* {@link grabRegion} grabs screen content of a region on the systems main display
246+
* @param regionToGrab The screen region to grab
246247
*/
247-
public async grabRegion(regionToGrab: Region): Promise<Image> {
248-
return this.vision.grabScreenRegion(regionToGrab);
248+
public async grabRegion(regionToGrab: Region | Promise<Region>): Promise<Image> {
249+
return this.vision.grabScreenRegion(await regionToGrab);
249250
}
250251

251252
private async saveImage(

0 commit comments

Comments
 (0)