2015-06-18 63 views
43

Ho creato un'applicazione AIR con due finestre. Il primo è la finestra principale (spark Windowed Application) e il secondo è un componente (scintilla finestra). Sto usando Java per catturare lo schermo del desktop con Flex-Java Bridge Flerry.Salta la finestra dalla cattura

ecco il codice per catturare lo schermo che è: -

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); 

Non voglio la finestra principale di flex di essere catturato. Dovrebbe essere ignorato (trasparente) dall'essere catturato.

È possibile modificare la configurazione del progetto Flex?

Se non è possibile eseguirlo in flex e java, in quale piattaforma può essere eseguita?

+0

[ 'SetWindowDisplayAffinity'] (https://msdn.microsoft.com/en-us/library/windows/desktop/dd375340.aspx)' (hWnd, WDA_MONITOR – IInspectable

+1

@iinspectable SetWindowDisplayAffinity non salta la finestra dall'essere catturata. Proteggerà semplicemente la finestra dall'essere catturata. Non voglio schermo nero al posto di quella finestra, voglio il lato posteriore della finestra di essere visualizzato. – Vishnu

+0

Come si suppone che qualcuno sappia ciò che si desidera, quando la domanda non specifica nemmeno il comportamento desiderato in remoto? Quello che hai chiesto nel tuo commento è - in generale - non possibile. – IInspectable

risposta

1

Se ho capito correttamente il problema.

È possibile utilizzare costruito in funzione/AS3 Flex per prendere uno screenshot dell'intera applicazione o di un particolare componente poi convertire in ByteArray e PngEncoder (o JPGEncoder, se si preferisce), che salvarlo ...

Ecco un esempio:

<?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:

Come ho pensato ho frainteso la richiesta ..

L'unico modo che posso pensare è:

  1. minimizzare l'applicazione (this.minimize();) o impostando l'alfa a 0 (this.alpha=0).
  2. Prendere schermata
  3. massimizzare l'applicazione (this.maximize();) o impostando l'alfa 1 (this.alpha=0).
+0

Siamo spiacenti. Voglio catturare lo schermo del desktop, non l'app flex. – Vishnu

+0

Oh ... dannazione ... ho frainteso ... risposta aggiornata. – Marcx

+0

Ciò provoca un effetto lampeggiante sullo schermo. Bitblt richiede 200 ms per acquisire lo schermo. L'ho provato. E non puoi usare "this.minimize" o "this.alpha' di flex app in java – Vishnu

0

Una soluzione che posso pensare è che è possibile spostare le finestre "indesiderate" fuori dall'acquisizione. (Sotto 0,0 coordinate) con un codice come questo.

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

e di

foo(); 
capture(); 
foo(); 
Problemi correlati