How can I take a window screenshot in Node.js?

前端 未结 2 2166
無奈伤痛
無奈伤痛 2021-02-15 12:20

I\'m in a research to find a way to take a screenshot of a window using Node.js, and I\'m trying to do this with node-ffi, but I don\'t know how... at a time I\'m stuck here:

2条回答
  •  [愿得一人]
    2021-02-15 12:42

    You could use a NPM package called "desktop-screenshot". It's very simple to use.

    Example on NPM:

    var screenshot = require('desktop-screenshot');
    
    screenshot("screenshot.png", function(error, complete) {
        if(error)
            console.log("Screenshot failed", error);
        else
            console.log("Screenshot succeeded");
    });
    

    https://www.npmjs.com/package/desktop-screenshot

提交回复
热议问题