Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing a desktop screenshot with javascript

Is it possible to capture a screenshot of the client's windows desktop using javascript? What about in linux and mac OS?

Clarification

This question has not been asked or answered, because I'm looking to capture the entire desktop, not just the browser. I would also like to capture 'native' screenshot rather than one that is recreated from some underlying representation (which would be impossible on any OS).

like image 660
Matt Sinclair Avatar asked Jul 19 '13 09:07

Matt Sinclair


People also ask

Can I take a screenshot with JavaScript?

A screenshot of any element in JavaScript can be taken using the html2canvas library. This library can be downloaded from its official website.

What is screen grabber JS?

GitHub - html-screen-capture-js/html-screen-capture-js: A tiny, highly-customizable, single-function javascript/typescript library that captures a webpage and returns a new lightweight, self-contained HTML document. The library removes all external file dependencies while preserving the original appearance of the page.

How do I capture a remote desktop screen?

“Ctrl” + “Alt” + “Print Screen”: This command takes a basic screenshot of the guest computer screen, saving it to the guest computer. If you are operating RDP in a windowed mode, this will save a picture of your whole screen.


1 Answers

There is an API called getDisplayMedia that lets you capture screen contents as a live MediaStream. It doesnt have a lot of support in browsers though.

https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture

If you just want a screenshot, you should be able to find a way to extract just a frame from the streaming video. Check this answer

like image 152
ajorquera Avatar answered Oct 12 '22 09:10

ajorquera