Search code examples
c#androidscreenshotslimdxbluestacks

Capture nonactive window with C#


I have a problem with making a screenshot of the window BlueStacks (it's Android emulator) with some game playing in it.

Firstly I tried CopyFromScreen method and it works perfect. But after sometime I want to make a screenshot of a window, when it is not showing to do some other job during it.

Soon I found nice solution - PrintWindow, but for some reason it takes black screen capture (I can see the frame of the Bluestacks window, but black square inside).

I thought it was fault of some 3D in that game and tried to use SlimDX library, it's great, but it didn't help - it captures only showing pixels, not the nonactive window.

So, how can I get the screenshot of the window by its hWnd, when it is not active? Or maybe I can use other methods of recieving info from Bluestacks? Does it have any API? I need picture of the game to recognize numbers.

Any solution would be greatly appreciated!


Solution

  • You can use ADB commands:

    adb shell /system/bin/screencap -p /sdcard/screenshot.png
    adb pull /sdcard/screenshot.pngc:\screenshot.png
    

    and your screenshot will be in C:\screenshot.png for more you can see Android Debug Bridge.