As @OscarRyz already mentioned AJAX call is irrelevant here.
You have to create java applet that calls new Robot().checkScreenCaptureAllowed()
. This will capture whole screen.
The problem is how to understand where the visible area is. You can probably do it. You have to create at least one visible element in your applet. This element could be even very small (e.g. one pixel), so user will not see it. Then you can invoke getLocationOnScreen()
that gives you the absolute coordinate on screen. If your java applet is in the top-left corner this is the point where your visible area starts.
JavaScript allows you to know the height and width of current window: window.innerWidht
and window.innerHeight
. So, you now you can take your screen capture and cut the area that you need.
But please take into consideration that new Robot().checkScreenCaptureAllowed()
checks READ_DISPLAY_PIXELS_PERMISSION
and I do not believe you have such permissions for unsigned applet, so you will have to sign your applet.
To avoid this problem take a look on this: http://html2canvas.hertzen.com/ - script that "captures" screen and uses JavaScript only.