How to get content of Window in gdi plus?

h4ever

Member
Aug 30, 2013
163
0
0
I work with AHK which works with gdip via dllcall function. I am interested how to do this in C++ because I would try to adopt the code to AHK as dll calls.

I have this window (the left one):
http://oi61.tinypic.com/302130y.jpg
And I need to receive handler of the ahk_class AOKTSMapView. I would like to get it to clipboard as a bitmap and rotate the map. Actually I don't need the black area, it could be trimmed.

For AHK, I have such start (this is not complete code, but the part which uses gdip) - this is a piece of code from ScreenCapture:
Code:
mDC := DllCall("CreateCompatibleDC", "Uint", 0)
hBM := CreateDIBSection(mDC, nW, nH)
oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
hDC := DllCall("GetDC", "Uint", 0)
DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)

So the AHK code knows the size of the rectangle. But I don't know the size of the rectangle so Want to ask you how to do it, to get the image, rotate it, crop it and finally to paste it to clipboard.

Last thing I need is to get location of the first pixel on screen and dimensions of the image.
 

cabri

Diamond Member
Nov 3, 2012
3,616
1
81
handle or handler?

HWND hWnd = FindWindow("ClassNameHere", "TitleHere");

From the handle (Window) you can get any child object and/or capture the drawing surface.

If there is just straight drawing on the Device context; you will have to analyze the bitmap to determine what you are looking for.
 

h4ever

Member
Aug 30, 2013
163
0
0
I think handle is correct. Can you pls give me some useful example? Probably the best would be if you would paste some C++ code, I have some basics about C++ learned and Visual C++ 2010 express installed. So if you give me some code I can try what it does in C++ and then find way how to do it in AHK.

I tried this code, but it produces thousand of errors :-/ of undeclared identifiers
http://stackoverflow.com/questions/21479921/capturing-the-contents-of-a-window-using-bitblt
 
Last edited: