admin
2022-07-08 ae66a5e07a2ebb455e83c65ded12697fd0fece98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "CaptureUtil.h"
 
HWND CaptureUtil::level2Frames[8];
std::list<FrameInfo> CaptureUtil::tempFrames;
 
BOOL CALLBACK CaptureUtil::EnumChildProc(HWND hwndChild, LPARAM lParam) {
    //TEXT("AfxWnd100s")
    char className[100];
    GetClassNameA(hwndChild, className, 100);
    if (string(className) == "AfxWnd100s") {
        RECT rect;
        GetWindowRect(hwndChild, &rect);
        bool show= IsWindowVisible(hwndChild);
        
        if (show&&rect.right - rect.left < 1000&& rect.right - rect.left>400)
        {
            FrameInfo info = FrameInfo();
            info.frame = hwndChild;
            info.position = rect;
            tempFrames.push_back(info);
        }
        
        /*
        if ( rect.right - rect.left>2800)
        {
            FrameInfo info = FrameInfo();
            info.frame = hwndChild;
            info.position = rect;
            tempFrames.push_back(info);
        }
        */
 
    }
    return TRUE;
}
void CaptureUtil::init(HWND l2win) {
    tempFrames.clear();
    HWND root = l2win;
 
    root = FindWindowEx(root, NULL, TEXT("AfxFrameOrView100s"), NULL);
 
    EnumChildWindows(root, EnumChildProc, NULL);
    //¸³Öµ
    std::list<FrameInfo>::iterator ele;
    int index = 0;
    for (ele = tempFrames.begin();ele != tempFrames.end();ele++) {
        if (index > 7) {
            break;
        }
        level2Frames[index++] = (*ele).frame;
    }
}
HWND CaptureUtil::getHWND(int index) {
    return level2Frames[index];
}
 
cv::Mat CaptureUtil::capture(int index) {
    cv::Mat cap = capture(getHWND(index));
    return cap;
}
 
 
cv::Mat  CaptureUtil::capture(HWND hwnd) {
    cv::Mat cap = _wss::screen_shot_by_window(hwnd);
    return cap;
}