0

I am building a messaging web application where I want to add a functionality to capture and upload the screenshot of any of the opened windows selected by the user.

Complete Use case: On the web app instead of uploading an image user will click a button (called capture) which will enable the user to take a screen capture of any of the selected window. This is similar to screenshot/screen clipping in outlook or office products. We need this functionality to be embedded in the web app running on the browser.

Example: A user is using my web app and wants to share a painting art s/he made using the paint application, s/he clicks on the 'capture' button and select the paint window which is opened and take a screenshot of that paint window and upload that image in the web app.

Is there any javascript library which can help me perform this action?

It is different from this question (Using HTML5/Canvas/JavaScript to take in-browser screenshots) as I am looking for the screenshot on different window rather than on the browser window.

Thank you.

KIA
  • 182
  • 2
  • 9
  • Possible duplicate of [Using HTML5/Canvas/JavaScript to take in-browser screenshots](https://stackoverflow.com/questions/4912092/using-html5-canvas-javascript-to-take-in-browser-screenshots) – hashedram Feb 22 '18 at 09:00
  • No, I have seen that question before posting this. There it is asked about taking a screenshot on a part of browser web page but here I am asking about taking a screenshot on other windows opened on the machine. – KIA Feb 22 '18 at 11:43

1 Answers1

0

It is not possible to capture screenshot, or do anything at all, outside of the DOM content in one tab/window.

Refer https://en.wikipedia.org/wiki/Same-origin_policy

A web page can only access its own contents. Not other web pages. Not things outside the window.

If you're looking for some tool to capture screenshots of any window and any web page, it should be a native application of that OS (windows app, android app, etc) and should use the tools/api's provided by that OS. That cannot be integrated directly into a web page.

The closest option is to let the user take a screenshot using whatever tool necessary and upload/paste that image onto your web page.

hashedram
  • 813
  • 7
  • 14