Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip window from being captured

I have created an AIR application which has two windows. First one is main window(spark Windowed Application) and the second one is a component(spark window). I am using Java to capture the Desktop screen with Flex-Java Bridge Flerry.

Here is the code to capture the screen which is:-

HDC hdcWindow = User32.INSTANCE.GetDC(hWnd); HDC hdcMemDC = GDI32.INSTANCE.CreateCompatibleDC(hdcWindow); RECT bounds = new RECT(); User32Extra.INSTANCE.GetClientRect(hWnd, bounds);  int width = bounds.right; int height = bounds.bottom ; HBITMAP hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcWindow, width, height);  HANDLE hOld = GDI32.INSTANCE.SelectObject(hdcMemDC, hBitmap); GDI32Extra.INSTANCE.BitBlt(hdcMemDC, 0, 0, width, height, hdcWindow, 0, 0, WinGDIExtra.SRCCOPY); 

I don't want the main flex window to be captured. It should skipped(transparent) from being captured.

Is that possible by changing the configuration of flex project?

If it cannot be done in flex and java, in what platform it can be done?

like image 514
Vishnu Avatar asked Jun 18 '15 03:06

Vishnu


People also ask

How do I capture only part of my screen?

Press Ctrl + PrtScn keys. The entire screen changes to gray including the open menu. Select Mode, or in earlier versions of Windows, select the arrow next to the New button. Select the kind of snip you want, and then select the area of the screen capture that you want to capture.

What is capturing window?

Use the Snipping Tool in Windows, which highlights sections of the screen and allows you to save it as an image. Search for snipping tool , and click to open it. You can also capture the image of either the entire screen or only the currently active window using the PrtScrn or Print Screen key.

How do I capture just the active window?

Alt + Print Screen To take a quick screenshot of the active window, use the keyboard shortcut Alt + PrtScn. This will snap your currently active window and copy the screenshot to the clipboard. You'll need to open the shot in an image editor to save it.

How do I capture a screenshot in Windows 10?

If you wish to capture your entire screen and automatically save the screenshot, tap the Windows key + Print Screen key. The display of your computer will briefly dim to indicate that a screenshot has just been captured. The screenshot will be saved to the Pictures > Screenshots folder.


1 Answers

If I understood correctly your problem.

You can use built in Flex/as3 function to take a screenshot of the entire application or a particular component then convert into bytearray and PngEncoder (or JPGEncoder if you prefer), than save it...

Here's an example:

<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"                         xmlns:s="library://ns.adobe.com/flex/spark"                         xmlns:mx="library://ns.adobe.com/flex/mx">        <fx:Script>         <![CDATA[             import mx.graphics.codec.PNGEncoder;              private function takeSnapshot(comp:DisplayObject):void {                 var bitmapData:BitmapData = new BitmapData(comp.width,comp.height,false,0x00000000);                 bitmapData.draw(comp, new Matrix());                  var fileStream:FileStream = new FileStream();                 fileStream.open(File.desktopDirectory.resolvePath("screenshot.png"), FileMode.UPDATE);                 fileStream.writeBytes(new PNGEncoder().encode(bitmapData));             }         ]]>     </fx:Script>         <s:BorderContainer width="100%" height="100%" backgroundColor="#ff00ff">         <s:Label text="this text and box should be saved"/>         <s:BorderContainer width="25%" height="25%" backgroundColor="#ffff00" horizontalCenter="0"                            id="extended"                            verticalCenter="0">             <s:Label text="this text and box should be saved" width="100%" maxDisplayedLines="5"/>         </s:BorderContainer>     </s:BorderContainer>         <s:Button bottom="0" left="0" label="screen" click="takeSnapshot(extended)"/> </s:WindowedApplication> 

EDIT:

As I thought I misunderstood the request..

The only way I can think of is to:

  1. Minimize the application (this.minimize();) or setting the alpha to 0 (this.alpha=0).
  2. Take the screenshot
  3. Maximize the application (this.maximize();) or setting the alpha to 1 (this.alpha=0).
like image 166
Marcx Avatar answered Sep 19 '22 09:09

Marcx