Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 跳过捕获的窗口_Java_Winapi_Apache Flex_Air_Jna - Fatal编程技术网

Java 跳过捕获的窗口

Java 跳过捕获的窗口,java,winapi,apache-flex,air,jna,Java,Winapi,Apache Flex,Air,Jna,我创建了一个AIR应用程序,它有两个窗口。第一个是主窗口(spark窗口应用程序),第二个是组件(spark窗口)。我使用Java捕获Flex Java Bridge Flerry的桌面屏幕 以下是捕获屏幕的代码:- HDC hdcWindow = User32.INSTANCE.GetDC(hWnd); HDC hdcMemDC = GDI32.INSTANCE.CreateCompatibleDC(hdcWindow); RECT bounds = new RECT(); User32Ext

我创建了一个AIR应用程序,它有两个窗口。第一个是主窗口(spark窗口应用程序),第二个是组件(spark窗口)。我使用Java捕获Flex Java Bridge Flerry的桌面屏幕

以下是捕获屏幕的代码:-

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);
我不希望捕获flex主窗口。它应该被跳过(透明)而不被捕获

通过改变flex项目的配置,这是可能的吗


如果不能在flex和java中完成,那么可以在什么平台上完成?

如果我正确理解了您的问题

您可以使用内置的Flex/as3函数获取整个应用程序或特定组件的屏幕截图,然后将其转换为bytearray和PngEncoder(或者JPGEncoder,如果您愿意),而不是保存它

下面是一个例子:

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

编辑:

我以为我误解了这个要求

我能想到的唯一方法是:

  • 最小化应用程序(
    this.Minimize();
    )或将alpha设置为0(
    this.alpha=0
  • 截图
  • 最大化应用程序(
    this.Maximize();
    )或将alpha设置为1(
    this.alpha=0

  • 我能想到的一个解决方案是,你可以把“不想要的”窗口从捕获中移出。(低于0,0坐标)使用类似的代码

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

    foo();
    capture();
    foo();
    

    (hWnd、WDA\U监视器)@iinspectable SetWindowDisplayAffinity不会跳过捕获的窗口。它只会保护窗口不被捕获。我不想用黑屏来代替那个窗口,我想让它后面的窗口显示出来。当你的问题甚至没有详细说明你想要的行为时,人们怎么知道你想要什么?一般来说,您在评论中要求的是不可能的。@IInspectable是否可以通过在hdcMemDC上绘制该窗口的hWnd背面来模拟该过程?抱歉。我想捕获桌面屏幕,而不是flex应用程序。这会在屏幕上产生闪烁效果。Bitblt需要200毫秒才能捕获屏幕。我试过了。您不能使用Java中flex应用程序的
    this.minimize
    this.alpha
    ,您可以警告用户并添加最小超时以避免闪烁效果(即500毫秒)吗?我使用它来持续共享屏幕。这对用户不友好。对不起,我没有主意了:D