Skip to content

(#278) Adjusted captureRegion and grabRegion parameters to accept Pro… #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/screen.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ export class ScreenClass {
*/
public async captureRegion(
fileName: string,
regionToCapture: Region,
regionToCapture: Region | Promise<Region>,
fileFormat: FileType = FileType.PNG,
filePath: string = cwd(),
fileNamePrefix: string = "",
fileNamePostfix: string = ""): Promise<string> {
const regionImage = await this.vision.grabScreenRegion(regionToCapture);
const regionImage = await this.vision.grabScreenRegion(await regionToCapture);
return this.saveImage(
regionImage,
fileName,
Expand All @@ -243,9 +243,10 @@ export class ScreenClass {

/**
* {@link grabRegion} grabs screen content of a region on the systems main display
* @param regionToGrab The screen region to grab
*/
public async grabRegion(regionToGrab: Region): Promise<Image> {
return this.vision.grabScreenRegion(regionToGrab);
public async grabRegion(regionToGrab: Region | Promise<Region>): Promise<Image> {
return this.vision.grabScreenRegion(await regionToGrab);
}

private async saveImage(
Expand Down