Taking a screenshot

The previously created static prototype may look fancy, but is not of much use. We need a service capable of taking screenshots and recording screencasts.

If it was about a screenshot of the application window, we would simply use the API on NW.js:

import * as fs from "fs"; function takeScreenshot( filePath ){   appWindow.capturePage(( img ) => {     fs.writeFileSync( filePath, img, "base64" );   }, {     format : "png",     datatype : "raw"   }); } 

But we need a screenshot of the screen and, therefore, we have to get access to display input. W3C includes a specification draft, "Media Capture and Streams" (http://bit.ly/2qTtLXX), which describes an API to capture displayed media (mediaDevices.getDisplayMedia). Unfortunately, at ...

Get Cross-platform Desktop Application Development: Electron, Node, NW.js, and React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.