From c108e5ba42168841311b74034d89c31556d628c4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 12 七月 2022 17:24:10 +0800
Subject: [PATCH] '完善'

---
 ConsoleApplication/CaptureUtil.cpp |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/ConsoleApplication/CaptureUtil.cpp b/ConsoleApplication/CaptureUtil.cpp
index c6f80f4..15b68d8 100644
--- a/ConsoleApplication/CaptureUtil.cpp
+++ b/ConsoleApplication/CaptureUtil.cpp
@@ -1,6 +1,7 @@
 #include "CaptureUtil.h"
 
 HWND CaptureUtil::level2Frames[8];
+HWND CaptureUtil::tradeQueueFrames[8];
 std::list<FrameInfo> CaptureUtil::tempFrames;
 
 BOOL CALLBACK CaptureUtil::EnumChildProc(HWND hwndChild, LPARAM lParam) {
@@ -36,19 +37,71 @@
 void CaptureUtil::init(HWND l2win) {
 	tempFrames.clear();
 	HWND root = l2win;
+	RECT rootRect;
+	GetWindowRect(root, &rootRect);
+	int rootHeight = (rootRect.bottom- rootRect.top);
 
 	root = FindWindowEx(root, NULL, TEXT("AfxFrameOrView100s"), NULL);
 
 	EnumChildWindows(root, EnumChildProc, NULL);
+
+	std::list<FrameInfo> tempL2;
+	std::list<FrameInfo> tempTrade;
+
 	//赋值
 	std::list<FrameInfo>::iterator ele;
-	int index = 0;
 	for (ele = tempFrames.begin();ele != tempFrames.end();ele++) {
-		if (index > 7) {
-			break;
+		FrameInfo frameInfo = *ele;
+		if (frameInfo.position.bottom - frameInfo.position.top > rootHeight/2) {
+			tempL2.push_back(frameInfo);
 		}
+		else {
+			//查找第一个子元素
+		    HWND temp =  FindWindowEx(frameInfo.frame, NULL,NULL, NULL);
+			RECT tempRect;
+			GetWindowRect(temp, &tempRect);
+		
+			while (!IsWindowVisible(temp) || tempRect.right- tempRect.left<100) {
+				temp= FindWindowEx(frameInfo.frame, temp, NULL, NULL);
+				GetWindowRect(temp, &tempRect);
+			}
+
+			HWND tempc = FindWindowEx(temp, NULL, NULL, NULL);
+			tempc = FindWindowEx(temp, tempc, NULL, NULL);
+
+			tempc = FindWindowEx(tempc, NULL, TEXT("SysListView32"), NULL);
+			GetWindowRect(tempc, &tempRect);
+			FrameInfo tempFrame = FrameInfo();
+			tempFrame.frame = tempc;
+			tempFrame.position = tempRect;
+
+			tempTrade.push_back(tempFrame);
+		}
+	}
+	//排序
+	tempL2.sort();
+	tempTrade.sort();
+
+
+	int index = 0;
+	for (ele = tempL2.begin();ele != tempL2.end();ele++) {
 		level2Frames[index++] = (*ele).frame;
 	}
+
+	index = 0;
+	for (ele = tempTrade.begin();ele != tempTrade.end();ele++) {
+		tradeQueueFrames[index++] = (*ele).frame;
+	}
+	//保存图片
+	for (int i = 0;i < 8;i++) {
+	cv::Mat img= ImgUtil::grayImage(capture(tradeQueueFrames[i]));
+	string path = "C:\\Users\\Administrator\\Desktop\\ocr\\trade_queue\\";
+	path.append(to_string(i)).append(".jpg");
+	cv::imwrite(path,img);
+	}
+
+
+
 }
 HWND CaptureUtil::getHWND(int index) {
 	return level2Frames[index];

--
Gitblit v1.8.0