Skip capture window

I created an AIR application that has two windows. The first is the main window (spark window application), and the second is the component (spark window). I use Java to capture the desktop screen using Flex-Java Bridge Flerry.

Here is the code for capturing the screen: -

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 do not want the main flex window to be captured. It should be skipped (transparent) from capture.

Is this possible by changing the configuration of the flex project?

If this cannot be done in flex and java, on which platform can this be done?

+43
java flex air winapi jna
Jun 18 '15 at 3:10
source share
2 answers

If I understand your problem correctly.

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

Here is 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:

  • Minimize the application ( this.minimize(); ) or set the alpha to 0 ( this.alpha=0 ).
  • Take a screenshot
  • Expand the application ( this.maximize(); ) or set the alpha to 1 ( this.alpha=0 ).
+1
Aug 27 '15 at 11:02
source share

The solution I can think of is that you can move the “unwanted” windows from the capture. (Below 0,0 coordinates) with some code like this.

 public void foo(){ this.xCoord = -this.xCoord; this.yCoord = -this.yCoord; } //Im not sure about the exact syntax but you should get the idea. 

and than

 foo(); capture(); foo(); 
0
Sep 17 '15 at 7:25
source share



All Articles