如何捕获客户端“桌面”部分的屏幕截图。使用HTML / JavaScript? [英] How to capture screenshot of parts of the client "desktop" using HTML/JavaScript ?
问题描述
我知道如何捕获网页,但我想知道如何在桌面上捕获桌面或其他应用程序?如果有任何方式突出显示部分屏幕。就像html2canvas对网页的作用一样,我们可以使用HTML / JS中的浏览器应用程序为桌面应用程序做些什么吗?
I know how to capture webpage, but I am asking to how capture desktop or another application in the desktop ? And if there is anyway to highlight parts of screen. Like how html2canvas does for webpages, can we do something for desktop applications using a browser app in HTML/JS ?
推荐答案
是的,它是可能的!
但据我所知只有Firefox和Chrome(我使用的是Chrome)。感谢屏幕截图和WebRTC。 有关WebRTC的更多信息
Yes, it is possible!
But as far as I know only for Firefox and Chrome (I used Chrome). Thanks to Screen Capturing and WebRTC. More info about WebRTC
我用了一个名为 RTCMultiConnection 的图书馆非常易于使用,但你也应该可以不用任何用途图书馆。
I used a library called RTCMultiConnection which is very easy to use, but you should be able to do that also without any use of a library.
这里,只是给你一个起点:
Here, just to give you a startingpoint:
// 1. Create the connection Objekt
var connection = new RTCMultiConnection();
// 2. Activate screen, which is the whole monitor, not only the browser window!
connection.session = {
screen: true,
data: false,
oneway: true
};
// 3. Create the callback for the stream
connection.onstream = function(event) {
// Make something with the event
// event.stream contains the stream, event.mediaElement the media
// I used event.mediaElement as parameter to draw the frage into an canvas; via context2d.drawImage(event.mediaElement, ...)
// Then I create an base64 String via canvas.toDataURL("image/png") and
// Don't forget to stop the stream if you just want to have one single image
};
// 4. Start Desktop Sharing
connection.open({
// you could register a onMediaCaptured callback here
});
这篇关于如何捕获客户端“桌面”部分的屏幕截图。使用HTML / JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!