zhangyang 6 лет назад
Родитель
Сommit
53f9ff011f

BIN
bin/Win32/Debug/zhipuzi_pay_plugin/db/pos.db


Разница между файлами не показана из-за своего большого размера
+ 85 - 1257
bin/Win32/Debug/zhipuzi_pay_plugin/log/pos.log


BIN
bin/Win32/Debug/zhipuzi_pay_plugin/zhipuzi_pay_plugin.exe


BIN
bin/Win32/Debug/zhipuzi_pay_plugin/zpzDll.dll


+ 111 - 22
zhipuzi_pay_plugin/wnd/CValueWnd.cpp

@@ -1,4 +1,4 @@
-#include "../pch/pch.h"
+#include "../pch/pch.h"
 #include "CValueWnd.h"
 
 #include "../tool/CComHelper.h"
@@ -22,29 +22,32 @@ void CValueWnd::Init()
 	BOOL isAdmin = CSystem::IsRunasAdmin();
 	if (isAdmin)
 	{
-		//MessageBox(m_hWnd, L"¹ÜÀíÔ±", L"111", MB_OK);
+		//MessageBox(m_hWnd, L"管�员", L"111", MB_OK);
 	}
 	else
 	{
-		//MessageBox(m_hWnd, L"·Ç¹ÜÀíÔ±", L"111", MB_OK);
+		//MessageBox(m_hWnd, L"�管�员", L"111", MB_OK);
 	}
 
 	SetHwnd(m_hWnd);
 
 	BOOL ret = InstallHook();
-	if (ret)
-	{
-		int a = 1;
-	}
 
-	int b = 1;
+	LONG id = GetWindowLongW((HWND)0x00211108, GWL_ID);
+	LONG b = id;
+
+	TCHAR szTitle[MAX_PATH];
+	LPWSTR lpWindowName = szTitle;
 
-	/*std::thread(&CValueWnd::ReadValue, this).detach();*/
+	::SendMessageW((HWND)0x00081342, WM_GETTEXT, (WPARAM)(MAX_PATH), (LPARAM)lpWindowName);
+	wstring a = lpWindowName;
+
+	std::thread(&CValueWnd::ReadValue, this).detach();
 }
 
 void CValueWnd::ReadValue()
 {
-	//¶ÁÈ¡´®¿ÚµÄģʽ
+	//读�串�的模�
 	//CComHelper helper;
 	//std::vector<std::wstring> comVector = helper.getComPort();
 
@@ -70,7 +73,7 @@ void CValueWnd::ReadValue()
 
 	//	while (true)
 	//	{
-	//		//¿ªÊ¼¶ÁÈ¡´®¿ÚµÄÊý¾Ý			
+	//		//开始读�串�的数�			
 	//		char a[1024] = { 0 };
 	//		serial.readFromComm(a, 1024);
 
@@ -81,8 +84,9 @@ void CValueWnd::ReadValue()
 
 	//	serial.closeComm();
 	//}
-	//}
-	//} 
+
+
+	FindValueWnd(L"");
 }
 
 LRESULT CValueWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -91,7 +95,7 @@ LRESULT CValueWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
 	styleValue &= ~WS_CAPTION;
 	::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
 
-	// °Ñ×Ô¼ºµÄ´°¿Ú¾ä±úÓë´°¿Ú»æÖƹÜÀíÆ÷¹Ò½ÓÔÚÒ»Æð
+	// 把自己的窗��柄与窗�绘制管�器挂接在一起
 	m_pm.Init(m_hWnd);
 
 	m_pm.AddPreMessageFilter(this);
@@ -101,10 +105,10 @@ LRESULT CValueWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
 	CControlUI* pRoot = builder.Create(_T("value.xml"), (UINT)0, NULL, &m_pm);
 	ASSERT(pRoot && "Failed to parse XML");
 
-	// °ÑÕâЩ¿Ø¼þ»æÖƵ½±¾´°¿ÚÉÏ
+	// 把这些控件绘制到本窗�上
 	m_pm.AttachDialog(pRoot);
 
-	// °Ñ×Ô¼º¼ÓÈëµ½CPaintManagerUIµÄm_aNotifiersÊý×éÖУ¬ÓÃÓÚ´¦ÀíNotifyº¯Êý
+	// 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处�Notify函数
 	m_pm.AddNotifier(this);
 
 	Init();
@@ -119,7 +123,7 @@ LRESULT CValueWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
 }
 
 /*
- *Õâ¸öÊÇ´°¿Ú±»Ïú»ÙµÄʱºòµ÷ÓõÄ
+ *这个是窗�被销�的时候调用的
  **/
 LRESULT CValueWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
@@ -144,7 +148,7 @@ LRESULT CValueWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
 
 LRESULT CValueWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	//ÔÚÕâÀïÉèÖý¹µã²ÅÓÐÓÃ
+	//在这里设置焦点�有用
 	CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
 
 	if (pAccountEdit)
@@ -183,7 +187,7 @@ LRESULT CValueWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
 
 LRESULT CValueWnd::OnKexianUpdate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	//ÊÕµ½ÁË¿ÍÏÔÊý¾ÝÏûÏ¢£¬¶ÁÈ¡¿ÍÏÔÊý¾Ý
+	//收到了客显数�消�,读�客显数�
 	char data[MAX_DATA_LENGTH] = { 0 };
 	int data_length = 0;
 
@@ -277,12 +281,12 @@ void CValueWnd::UpdateKexian(char* data, int length)
 	int nTypePos = new_data.find(type_command, nPos + 1);
 	if (nTypePos == new_data.npos)
 	{
-		//ûÓÐÀàÐÍÐÅÏ¢£¬ÓÐЩÊÕÒø»ú£¨±ÈÈç˼ѸÌìµê£©¾ÍÊDz»´«ÀàÐÍÐÅÏ¢£¬ÕâÖÖÖ»Óд«Ê²Ã´ÏÔʾʲôÁË
+		//没有类型信�,有些收银机(比如�迅天店)就是�传类型信�,这��有传什么显示什么了
 		int nTabPos = new_data.find("\r", nPos + 1);
 
 		if (nTabPos == new_data.npos)
 		{
-			//ÖÆ±í·ûҲûÓÐ
+			//制表符也没有
 			return;
 		}
 
@@ -300,7 +304,7 @@ void CValueWnd::UpdateKexian(char* data, int length)
 
 		if (value_type == "2")
 		{
-			//Õâ¸ö±íʾÊÇ×ܼƵģ¬ÄÇô¾ÍҪˢнð¶îÏÔʾ
+			//这个表示是总计的,那么就�刷新金�显示
 			CLabelUI* valueLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("value")));
 
 			std::string money_show = CLewaimaiString::DoubleToString(atof(money.c_str()), 2);
@@ -311,3 +315,88 @@ void CValueWnd::UpdateKexian(char* data, int length)
 	return;
 }
 
+BOOL CALLBACK EnumChildProc(_In_ HWND   hwnd, _In_ LPARAM lParam)
+{
+	TCHAR szTitle[MAX_PATH] = { 0 };
+	TCHAR szClass[MAX_PATH] = { 0 };
+	int nMaxCount = MAX_PATH - 1;
+
+	LPWSTR lpClassName = szClass;
+	LPWSTR lpWindowName = szTitle;
+
+	::SendMessageW(hwnd, WM_GETTEXT, (WPARAM)(MAX_PATH), (LPARAM)lpWindowName);
+	GetClassName(hwnd, lpClassName, nMaxCount);
+
+	LOG_INFO("[Child window] window handle: " << hwnd << " window name: "
+		<< lpWindowName << " class name " << lpClassName); 
+
+	return TRUE;
+}
+
+BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
+{
+	char szTitle[MAX_PATH] = { 0 };
+	char szClass[MAX_PATH] = { 0 };
+	int nMaxCount = MAX_PATH;
+
+	LPSTR lpClassName = szClass;
+	LPSTR lpWindowName = szTitle;
+
+	::SendMessageW(hwnd, WM_GETTEXT, (WPARAM)(MAX_PATH), (LPARAM)lpWindowName);
+	GetClassNameA(hwnd, lpClassName, nMaxCount);
+
+	LOG_INFO( "[Parent window] window handle: " << hwnd << " window name: "
+		<< lpWindowName << " class name " << lpClassName);
+
+	EnumChildWindows(hwnd, EnumChildProc, lParam);
+
+	return TRUE;
+}
+
+//�历所有�窗�的�窗� , Z��历
+void print_window2(HWND parent, int level)
+{
+	HWND child = NULL;
+	TCHAR buf[MAX_PATH] = { 0 };
+
+	do {
+		child = FindWindowExW(parent, child, L"WindowsForms10.STATIC.app.0.13965fa_r9_ad1", L"Â¥505");
+
+		if (child)
+		{
+			memset(buf, 0, sizeof(TCHAR) * MAX_PATH);
+			::SendMessageW(child, WM_GETTEXT, (WPARAM)(MAX_PATH), (LPARAM)buf);
+			LOG_INFO("CHILD handle:" << child << ",title:" << buf);
+
+			print_window2(child, level + 1);
+		}
+	} while (child);
+}
+
+//�历所有 explore 下的窗� , Z��历
+void print_window()
+{
+	HWND child = NULL;
+	TCHAR buf[MAX_PATH] = { 0 };
+
+	do {
+		//查找 Explore 下的一个窗�,如果能找到则根� Explore 下的child 继续找
+		child = FindWindowEx(NULL, child, NULL, L"天店�饮");
+
+		//�历�窗�们
+		if (child)
+		{
+			memset(buf, 0, sizeof(TCHAR) * MAX_PATH);
+			::SendMessageW(child, WM_GETTEXT, (WPARAM)(MAX_PATH), (LPARAM)buf);
+			LOG_INFO("FATHER handle:" << child << ",title:" << buf);
+
+			::EnumChildWindows(child, EnumChildProc, NULL);
+		}
+	} while (child);
+}
+
+void CValueWnd::FindValueWnd(std::wstring value)
+{
+	print_window();
+}
+

+ 7 - 0
zhipuzi_pay_plugin/wnd/CValueWnd.h

@@ -3,6 +3,11 @@
 #include "../pch/pch.h"
 #include <zpzDll/zpzDll.h>
 
+struct ValueWnd
+{
+
+};
+
 class CValueWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
 {
 public:
@@ -52,6 +57,8 @@ public:
 private:
 	void UpdateKexian(char* data, int length);
 
+	void FindValueWnd(std::wstring value);
+
 public:
 	CPaintManagerUI m_pm;
 };

+ 8 - 2
zpzDll/zpzDll.cpp

@@ -21,8 +21,14 @@ extern HINSTANCE g_Inst;
 /*
  *钩子过程函数,不做任何处理,因为目的仅仅是把dll注入到进程
  **/
-LRESULT CALLBACK SHELLProc(int nCode, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
 {
+	CWPSTRUCT *pMsg = (CWPSTRUCT *)lParam;
+	if (pMsg->hwnd == (HWND)0x001E11F2)
+	{
+		int a = 1;
+	}
+
 	return CallNextHookEx(g_Hook, nCode, wParam, lParam);
 }
 
@@ -33,7 +39,7 @@ BOOL InstallHook()
 {
 	if (g_Hook == NULL)
 	{
-		g_Hook = SetWindowsHookEx(WH_CALLWNDPROC, SHELLProc, g_Inst, 0);
+		g_Hook = SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, g_Inst, 0);
 
 		if (g_Hook != NULL)
 		{