I am trying to make a program to work on top of an existing GUI to annotate it and provide extra calculations and statistical information. I want to do this using image reco
One simple way is using the PrintWindow
API (which is an automated Alt + Print basically). The following example takes a screenshot of the calculator, but you would just have to replace the handles.
void CScreenShotDlg::OnPaint()
{
// device context for painting
CPaintDC dc(this);
// Get the window handle of calculator application.
HWND hWnd = ::FindWindow( 0, _T( "Calculator" ));
// Take screenshot.
PrintWindow( hWnd,
dc.GetSafeHdc(),
0 );
}
(see https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-printwindow )
I think CImage class will be helpful.
void CreateImage(HWND hwnd)
{
CImage img;
img.m_hDC = ::GetWindowDC(hwnd);
img.Save(strFileName);
}