Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Screen

Screen class provides methods to access screen content of a systems main display

Hierarchy

  • Screen

Index

Constructors

Methods

Object literals

Constructors

constructor

Methods

capture

  • capture(fileName: string, fileFormat?: FileType, filePath?: string, fileNamePrefix?: string, fileNamePostfix?: string): Promise<string>
  • capture captures a screenshot of a systems main display

    Parameters

    • fileName: string

      Basename for the generated screenshot

    • Default value fileFormat: FileType = FileType.PNG

      The FileType for the generated screenshot

    • Default value filePath: string = cwd()

      The output path for the generated screenshot (Default: {@link cwd})

    • Default value fileNamePrefix: string = ""

      Filename prefix for the generated screenshot (Default: empty)

    • Default value fileNamePostfix: string = ""

      Filename postfix for the generated screenshot (Default: empty)

    Returns Promise<string>

captureRegion

  • captureRegion(fileName: string, regionToCapture: Region, fileFormat?: FileType, filePath?: string, fileNamePrefix?: string, fileNamePostfix?: string): Promise<string>
  • captureRegion captures a screenshot of a region on the systems main display

    Parameters

    • fileName: string

      Basename for the generated screenshot

    • regionToCapture: Region

      The region of the screen to capture in the screenshot

    • Default value fileFormat: FileType = FileType.PNG

      The FileType for the generated screenshot

    • Default value filePath: string = cwd()

      The output path for the generated screenshot (Default: {@link cwd})

    • Default value fileNamePrefix: string = ""

      Filename prefix for the generated screenshot (Default: empty)

    • Default value fileNamePostfix: string = ""

      Filename postfix for the generated screenshot (Default: empty)

    Returns Promise<string>

find

  • find(templateImageFilename: string, params?: LocationParameters): Promise<Region>
  • find will search for a template image on a systems main screen

    Parameters

    • templateImageFilename: string

      Filename of the template image, relative to Screen.config.resourceDirectory

    • Optional params: LocationParameters

      {@link LocationParameters} which are used to fine tune search region and / or match confidence

    Returns Promise<Region>

height

  • height(): Promise<number>
  • height returns the main screen height This refers to the hardware resolution. Screens with higher pixel density (e.g. retina displays in MacBooks) might have a higher height in in actual pixels

    Returns Promise<number>

highlight

on

  • on registeres a callback which is triggered once a certain template image is found

    Parameters

    Returns void

waitFor

  • waitFor(templateImageFilename: string, timeoutMs?: number, params?: LocationParameters): Promise<Region>
  • waitFor searches for a template image for a specified duration

    Parameters

    • templateImageFilename: string

      Filename of the template image, relative to Screen.config.resourceDirectory

    • Default value timeoutMs: number = 5000

      Timeout in milliseconds after which waitFor fails

    • Optional params: LocationParameters

      {@link LocationParameters} which are used to fine tune search region and / or match confidence

    Returns Promise<Region>

width

  • width(): Promise<number>
  • width returns the main screen width This refers to the hardware resolution. Screens with higher pixel density (e.g. retina displays in MacBooks) might have a higher width in in actual pixels

    Returns Promise<number>

Object literals

config

config: object

Config object for Screen class

autoHighlight

autoHighlight: boolean = false

Configure whether to auto highlight all search results or not

confidence

confidence: number = 0.99

Configures the required matching percentage for template images to be declared as a match

highlightDurationMs

highlightDurationMs: number = 500

Configure highlighting duration

highlightOpacity

highlightOpacity: number = 0.25

Configure opacity of highlight window

resourceDirectory

resourceDirectory: string = cwd()

Configures the path from which template images are loaded from