Skip to main content
Module

x/swissKnife/mod.ts>screenshot

Deno Swiss Knife tools
Latest
function screenshot
import { screenshot } from "https://deno.land/x/swissKnife@1.8/mod.ts";

Capture screenshot

Examples

Example 1

import * as swissKnife from "https://deno.land/x/swissKnife/mod.ts"
await swissKnife.screenshot("c:\\myfolder\\myfile.png")

Example 2

import * as swissKnife from "https://deno.land/x/swissKnife/mod.ts"
let res = await swissKnife.screenshot("c:\\myfolder\\myfile.png", "Dual") //take a screenshot of both screens

Example 3

import * as swissKnife from "https://deno.land/x/swissKnife/mod.ts"
let res = await swissKnife.screenshot("c:\\myfolder\\myfile.png", "Window") //Also you can specify the current active window

Example 4

import * as swissKnife from "https://deno.land/x/swissKnife/mod.ts"
let res = await swissKnife.screenshot("c:\\myfolder\\myfile.png", "Single", {
  x: 10,
  y: 30,
  width: 200,
  height: 150
}) //The third parameter allows you to specify the coordinates, width and height of the area

Parameters

imagePath: string

local path to save the PNG image

optional
monitor: Monitor = [UNSUPPORTED]

Monitor options, "Single", "Dual", or "Window"

optional
screen: Screen

{x, y, width, height} Screen option

Returns

Promise<string>

the saved image path