How can I take a screenshot of one monitor / screen in Node JS? What libraries do I need and how do I use them? It needs to be able to successfully write to a file the contents of the entire monitor.
I can't seem to find anything but how to take screenshots of webpages, or specific windows. Thanks for helping!
You can try the screenshot-desktop
npm module. It's cross platform (Linux, Mac, Windows) and can save directly to a file.
Install:
$ npm install --save screenshot-desktop
Use:
const screenshot = require('screenshot-desktop')
screenshot({ filename: 'shot.jpg' }).then((imgPath) => {
// imgPath: absolute path to screenshot
// created in current working directory named shot.png
});
// absolute paths work too. so do pngs
screenshot({ filename: '/Users/brian/Desktop/demo.png' })