使用 javascript 捕获桌面屏幕截图 [英] Capturing a desktop screenshot with javascript

查看:157
本文介绍了使用 javascript 捕获桌面屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用javascript捕获客户端Windows桌面的屏幕截图?在 linux 和 mac OS 中呢?

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

澄清

这个问题没有被问到或回答过,因为我希望捕获整个桌面,而不仅仅是浏览器.我还想捕获本机"屏幕截图,而不是从某些底层表示重新创建的屏幕截图(这在任何操作系统上都是不可能的).

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).

推荐答案

有一个名为 getDisplayMedia 的 API,可让您将屏幕内容捕获为实时 MediaStream.虽然它在浏览器中没有很多支持.

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

这篇关于使用 javascript 捕获桌面屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆