Browse Source

【模块名称】
GM模块
【问题原因】
格式化代码
【修改描述】

【测试结果】

sat23 3 years ago
parent
commit
0ecfebd3b0
51 changed files with 5514 additions and 5357 deletions
  1. 1 1
      gm/3rd_party/src/kiero.cpp
  2. 17 13
      gm/gm/algorithm/AStar.hpp
  3. 53 52
      gm/gm/background/Hook/DisplayHook.cpp
  4. 2 2
      gm/gm/background/Hook/DisplayHook.h
  5. 44 44
      gm/gm/background/Hook/HookExport.cpp
  6. 0 1
      gm/gm/background/Hook/HookExport.h
  7. 190 193
      gm/gm/background/Hook/InputHook.cpp
  8. 1 1
      gm/gm/background/Hook/InputHook.h
  9. 12 9
      gm/gm/background/display/IDisplay.cpp
  10. 6 13
      gm/gm/background/display/IDisplay.h
  11. 2 1
      gm/gm/background/display/frameInfo.h
  12. 15 41
      gm/gm/background/display/opDxGL.cpp
  13. 2 3
      gm/gm/background/display/opDxGL.h
  14. 248 234
      gm/gm/background/display/opGDI.cpp
  15. 6 7
      gm/gm/background/display/opGDI.h
  16. 1 1
      gm/gm/background/keypad/Bkkeypad.cpp
  17. 1 4
      gm/gm/background/keypad/Bkkeypad.h
  18. 113 113
      gm/gm/background/keypad/winkeypad.cpp
  19. 1 1
      gm/gm/background/keypad/winkeypad.h
  20. 9 20
      gm/gm/background/mouse/opMouseDx.cpp
  21. 7 5
      gm/gm/background/mouse/opMouseDx.h
  22. 285 249
      gm/gm/background/mouse/opMouseWin.cpp
  23. 4 4
      gm/gm/background/mouse/opMouseWin.h
  24. 34 37
      gm/gm/background/opBackground.cpp
  25. 6 10
      gm/gm/background/opBackground.h
  26. 11 7
      gm/gm/core/Cmder.h
  27. 13 13
      gm/gm/core/Pipe.cpp
  28. 2 1
      gm/gm/core/Pipe.h
  29. 1 1
      gm/gm/core/globalVar.h
  30. 33 18
      gm/gm/core/helpfunc.cpp
  31. 21 13
      gm/gm/core/helpfunc.h
  32. 21 17
      gm/gm/core/opEnv.cpp
  33. 9 9
      gm/gm/core/opEnv.h
  34. 66 58
      gm/gm/core/optype.h
  35. 0 4
      gm/gm/gm.vcxproj
  36. 3 12
      gm/gm/gm.vcxproj.filters
  37. 1041 1022
      gm/gm/imageProc/ImageLoc.cpp
  38. 31 37
      gm/gm/imageProc/ImageLoc.h
  39. 43 41
      gm/gm/imageProc/ImageProc.cpp
  40. 16 16
      gm/gm/imageProc/ImageProc.h
  41. 12 12
      gm/gm/imageProc/imageView.hpp
  42. 136 127
      gm/gm/libop.cpp
  43. 28 32
      gm/gm/libop.h
  44. 3 7
      gm/gm/winapi/Injecter.cpp
  45. 3 3
      gm/gm/winapi/Injecter.h
  46. 43 26
      gm/gm/winapi/MemoryEx.cpp
  47. 4 3
      gm/gm/winapi/MemoryEx.h
  48. 2891 2792
      gm/gm/winapi/WinApi.cpp
  49. 18 19
      gm/gm/winapi/WinApi.h
  50. 4 5
      gm/gm/winapi/query_api.cpp
  51. 1 3
      gm/gm/winapi/query_api.h

+ 1 - 1
gm/3rd_party/src/kiero.cpp

@@ -738,7 +738,7 @@ int kiero::unbind() {
 	{
 		MH_DisableHook(MH_ALL_HOOKS);
 		ret = MH_RemoveHook(MH_ALL_HOOKS);
-		
+
 		kiero::shutdown();
 		//MessageBoxA(NULL, MH_StatusToString((MH_STATUS)ret), "", 0);
 		//MH_DisableHook((void*)g_methodsTable[_index]);

+ 17 - 13
gm/gm/algorithm/AStar.hpp

@@ -7,21 +7,23 @@
 #include <vector>
 
 using std::list;
-
 using std::set;
 using std::list;
 using std::vector;
-class AStar {
+
+class AStar 
+{
 public:
-	struct Vec2i { 
+	struct Vec2i {
 		int x, y;
 		bool operator==(const Vec2i& rhs)const {
-			return x == rhs.x&&y == rhs.y;
+			return x == rhs.x && y == rhs.y;
 		}
 		Vec2i operator+(const Vec2i& rhs)const {
 			return Vec2i{ x + rhs.x,y + rhs.y };
 		}
 	};
+
 	struct Node {
 		int F, G;
 		Vec2i pos;
@@ -38,32 +40,36 @@ public:
 			pos = rhs.pos;
 			return *this;
 		}*/
-
 	};
+
 	struct Nodeless
 	{
 		bool operator()(const Node& lhs, const Node& rhs) const {
 			return lhs.pos.x < rhs.pos.y || (lhs.pos.x == rhs.pos.x && lhs.pos.y < rhs.pos.y);
 		}
 	};
+
 	struct Vec2less {
 		bool operator()(const Vec2i& lhs, const Vec2i& rhs) const {
 			return lhs.x < rhs.x || (lhs.x == rhs.x && lhs.y < rhs.y);
 		}
 	};
+
 	AStar() {
 		_start.x = _start.y = 0;
 		_end.x = _end.y = 0;
 		//_start < _end;
 
 	}
+
 	bool outside(Vec2i pos) {
 		return pos.x<0 || pos.x>_mapSize.x || pos.y<0 || pos.y>_mapSize.y;
 	}
-	void set_map(int w,int h, const vector<Vec2i>& wall) {
+
+	void set_map(int w, int h, const vector<Vec2i>& wall) {
 		_mapSize.x = w; _mapSize.y = h;
 		_wallset.clear();
-		for (auto&it : wall) {
+		for (auto& it : wall) {
 			_wallset.insert(it);
 		}
 		/*	Vector2i tp;
@@ -74,7 +80,8 @@ public:
 				_wallset.insert({ i,mapSize.y });
 			}*/
 	}
-	void findpath(int beginX, int beginY,int endX,int endY, list<Vec2i>&path) {
+
+	void findpath(int beginX, int beginY, int endX, int endY, list<Vec2i>& path) {
 		_openset.clear();
 		_closedset.clear();
 		path.clear();
@@ -82,7 +89,7 @@ public:
 		_end.x = endX; _end.y = endY;
 		if (outside(_start) || outside(_end))
 			return;
-	
+
 		Node curr_node;
 		curr_node.pos = _start;
 		_openset.insert(curr_node);
@@ -135,11 +142,8 @@ public:
 				pnode = pnode->parent;
 			}
 		}
-
-
-
 	}
-	
+
 private:
 	//Eigen::
 	Vec2i _start, _end;

+ 53 - 52
gm/gm/background/Hook/DisplayHook.cpp

@@ -8,7 +8,6 @@
 #include "../../include/promutex.h"
 #include <exception>
 #include <ddraw.h>
-
 #include "../../../3rd_party/include/kiero.h"
 #include <gl\gl.h>
 #include <gl\glu.h>
@@ -19,6 +18,7 @@
 #include <wingdi.h>
 #include <atlbase.h>
 #include "../display/frameInfo.h"
+
 #define DEBUG_HOOK 0
 HWND DisplayHook::render_hwnd = NULL;
 int DisplayHook::render_type = 0;
@@ -45,7 +45,8 @@ unsigned int __stdcall gl_hkeglSwapBuffers(void* dpy, void* surface);
 //glfinish
 void __stdcall gl_hkglFinish(void);
 
-int DisplayHook::setup(HWND hwnd_, int render_type_) {
+int DisplayHook::setup(HWND hwnd_, int render_type_)
+{
 	DisplayHook::render_hwnd = hwnd_;
 	wsprintf(DisplayHook::shared_res_name, SHARED_RES_NAME_FORMAT, hwnd_);
 	wsprintf(DisplayHook::mutex_name, MUTEX_NAME_FORMAT, hwnd_);
@@ -74,14 +75,13 @@ int DisplayHook::setup(HWND hwnd_, int render_type_) {
 		render_type = kiero::RenderType::OpenGL;
 		idx = 0; address = gl_hkglBegin;
 	}
-	else if(render_type_==RDT_GL_ES){
+	else if (render_type_ == RDT_GL_ES) {
 		render_type = kiero::RenderType::OpenglES;
 		idx = 0; address = gl_hkeglSwapBuffers;
 	}
-	else if(render_type_==RDT_GL_FI){
+	else if (render_type_ == RDT_GL_FI) {
 		render_type = kiero::RenderType::OpenGL;
 		idx = 3; address = gl_hkglFinish;
-
 	}
 	else {
 		render_type = kiero::RenderType::None;
@@ -90,19 +90,20 @@ int DisplayHook::setup(HWND hwnd_, int render_type_) {
 	if (ret != kiero::Status::Success) {
 		return ret;
 	}
-		
 
 	is_capture = kiero::bind(idx, &old_address, address);
 	return is_capture;
 }
 
-int DisplayHook::release() {
+int DisplayHook::release()
+{
 	is_capture = 0;
 	int ret = kiero::unbind();
 	return 1;
 }
 
-static void CopyImageData(char*  dst_, const char* src_, int rows_, int cols_,int rowPitch, int fmt_) {
+static void CopyImageData(char* dst_, const char* src_, int rows_, int cols_, int rowPitch, int fmt_)
+{
 	//assert(rowsPitch >= cols_ * 4);
 	if (rowPitch == cols_ * (fmt_ == IBF_R8G8B8 ? 3 : 4)) {
 		if (fmt_ == IBF_B8G8R8A8) {
@@ -111,7 +112,7 @@ static void CopyImageData(char*  dst_, const char* src_, int rows_, int cols_,in
 		else if (fmt_ == IBF_R8G8B8A8) {
 			//pixels count
 			int n = rows_ * cols_;
-			
+
 			for (int i = 0; i < n; ++i) {
 				dst_[0] = src_[2];//b
 				dst_[1] = src_[1];//g
@@ -139,11 +140,9 @@ static void CopyImageData(char*  dst_, const char* src_, int rows_, int cols_,in
 				dst_ += dstPitch;
 				src_ += rowPitch;
 			}
-			
 		}
 		else if (fmt_ == IBF_R8G8B8A8) {
 			//pixels count
-			
 			for (int i = 0; i < rows_; ++i) {
 				for (int j = 0; j < cols_; ++j) {
 					const char* p = src_ + j * 4;//offset 
@@ -154,9 +153,9 @@ static void CopyImageData(char*  dst_, const char* src_, int rows_, int cols_,in
 					dst_ += 4;//notirc that dst ptr is increasing
 				}
 				src_ += rowPitch;//row increase
-				
+
 			}
-			
+
 		}
 		else {
 			for (int i = 0; i < rows_; ++i) {
@@ -173,10 +172,10 @@ static void CopyImageData(char*  dst_, const char* src_, int rows_, int cols_,in
 			}
 		}
 	}
-	
 }
 
-static DXGI_FORMAT GetDxgiFormat(DXGI_FORMAT format) {
+static DXGI_FORMAT GetDxgiFormat(DXGI_FORMAT format) 
+{
 	if (format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB) {
 		return DXGI_FORMAT_B8G8R8A8_UNORM;
 	}
@@ -186,7 +185,8 @@ static DXGI_FORMAT GetDxgiFormat(DXGI_FORMAT format) {
 	return format;
 }
 
-static void formatFrameInfo(void* dst,HWND hwnd, int w, int h) {
+static void formatFrameInfo(void* dst, HWND hwnd, int w, int h)
+{
 	static FrameInfo frameInfo = {};
 	frameInfo.hwnd = (unsigned __int64)hwnd;
 	frameInfo.frameId++;
@@ -197,10 +197,10 @@ static void formatFrameInfo(void* dst,HWND hwnd, int w, int h) {
 	memcpy(dst, &frameInfo, sizeof(frameInfo));
 }
 
-
 //------------------------dx9-------------------------------
 //screen capture
-HRESULT dx9_capture(LPDIRECT3DDEVICE9 pDevice) {
+HRESULT dx9_capture(LPDIRECT3DDEVICE9 pDevice) 
+{
 	//save bmp
 	//setlog("dx9screen_capture");
 	HRESULT hr = NULL;
@@ -237,14 +237,15 @@ HRESULT dx9_capture(LPDIRECT3DDEVICE9 pDevice) {
 	if (mem.open(DisplayHook::shared_res_name) && mutex.open(DisplayHook::mutex_name)) {
 		mutex.lock();
 		uchar* pshare = mem.data<byte>();
-		formatFrameInfo(pshare,DisplayHook::render_hwnd, surface_Desc.Width, surface_Desc.Height);
-		memcpy(pshare + sizeof(FrameInfo), (byte*)lockedRect.pBits, lockedRect.Pitch*surface_Desc.Height);
+		formatFrameInfo(pshare, DisplayHook::render_hwnd, surface_Desc.Width, surface_Desc.Height);
+		memcpy(pshare + sizeof(FrameInfo), (byte*)lockedRect.pBits, lockedRect.Pitch * surface_Desc.Height);
 		mutex.unlock();
 	}
 	pTex->UnlockRect(0);
-	
+
 	return hr;
 }
+
 //dx9 hooked EndScene function
 HRESULT STDMETHODCALLTYPE dx9_hkEndScene(IDirect3DDevice9* thiz)
 {
@@ -259,11 +260,12 @@ HRESULT STDMETHODCALLTYPE dx9_hkEndScene(IDirect3DDevice9* thiz)
 
 //-----------------------dx10----------------------------------
 //screen capture
-void dx10_capture(IDXGISwapChain* pswapchain) {
-	using Texture2D = ID3D10Texture2D * ;
+void dx10_capture(IDXGISwapChain* pswapchain)
+{
+	using Texture2D = ID3D10Texture2D*;
 
 	HRESULT hr;
-	ID3D10Device *pdevices = nullptr;
+	ID3D10Device* pdevices = nullptr;
 	ID3D10Resource* backbuffer = nullptr;
 	Texture2D textDst = nullptr;
 	//LPD3D10BLOB pblob = nullptr;
@@ -290,8 +292,6 @@ void dx10_capture(IDXGISwapChain* pswapchain) {
 	//backbuffer->GetDesc(&desc);
 	// If texture is multisampled, then we can use ResolveSubresource to copy it into a non-multisampled texture
 	//Texture2D textureResolved = nullptr;
-
-
 	D3D10_TEXTURE2D_DESC textDesc = {};
 	textDesc.Format = GetDxgiFormat(desc.BufferDesc.Format);
 	textDesc.Width = desc.BufferDesc.Width;
@@ -339,8 +339,8 @@ void dx10_capture(IDXGISwapChain* pswapchain) {
 		mutex.lock();
 		//memcpy(mem.data<char>(), mapText.pData, textDesc.Width*textDesc.Height * 4);
 		uchar* pshare = mem.data<byte>();
-		formatFrameInfo(pshare,DisplayHook::render_hwnd, textDesc.Width, textDesc.Height);
-		CopyImageData((char*)pshare+ sizeof(FrameInfo), (char*)mapText.pData, textDesc.Height, textDesc.Width, mapText.RowPitch, fmt);
+		formatFrameInfo(pshare, DisplayHook::render_hwnd, textDesc.Width, textDesc.Height);
+		CopyImageData((char*)pshare + sizeof(FrameInfo), (char*)mapText.pData, textDesc.Height, textDesc.Width, mapText.RowPitch, fmt);
 		mutex.unlock();
 	}
 	else {
@@ -357,8 +357,10 @@ void dx10_capture(IDXGISwapChain* pswapchain) {
 	//pblob->Release();
 	//setlog("pblob->Release()");
 }
+
 //dx10 hook Present
-HRESULT STDMETHODCALLTYPE dx10_hkPresent(IDXGISwapChain* thiz, UINT SyncInterval, UINT Flags) {
+HRESULT STDMETHODCALLTYPE dx10_hkPresent(IDXGISwapChain* thiz, UINT SyncInterval, UINT Flags)
+{
 	typedef long(__stdcall* Present_t)(IDXGISwapChain* pswapchain, UINT x1, UINT x2);
 	if (is_capture)
 		dx10_capture(thiz);
@@ -369,10 +371,10 @@ HRESULT STDMETHODCALLTYPE dx10_hkPresent(IDXGISwapChain* thiz, UINT SyncInterval
 
 //------------------------dx11----------------------------------
 //screen capture
-void dx11_capture(IDXGISwapChain* swapchain) {
-
+void dx11_capture(IDXGISwapChain* swapchain)
+{
 	//setlog("d3d11 cap");
-	using Texture2D = ID3D11Texture2D * ;
+	using Texture2D = ID3D11Texture2D*;
 	HRESULT hr = 0;
 	IDXGIResource* backbufferptr = nullptr;
 	ID3D11Resource* backbuffer = nullptr;
@@ -463,7 +465,7 @@ void dx11_capture(IDXGISwapChain* swapchain) {
 		formatFrameInfo(pshare, DisplayHook::render_hwnd, textDesc.Width, textDesc.Height);
 		//CopyImageData((char*)pshare + sizeof(FrameInfo), (char*)mapText.pData, textDesc.Height, textDesc.Width, fmt);
 		static_assert(sizeof(FrameInfo) == 28);
- 
+
 		CopyImageData((char*)pshare + sizeof(FrameInfo), (char*)mapSubres.pData, textDesc.Height, textDesc.Width, mapSubres.RowPitch, fmt);
 		mutex.unlock();
 	}
@@ -497,7 +499,8 @@ void dx11_capture(IDXGISwapChain* swapchain) {
 }
 
 //hooked present
-HRESULT __stdcall dx11_hkPresent(IDXGISwapChain* thiz, UINT SyncInterval, UINT Flags) {
+HRESULT __stdcall dx11_hkPresent(IDXGISwapChain* thiz, UINT SyncInterval, UINT Flags)
+{
 	typedef long(__stdcall* Present_t)(IDXGISwapChain* pswapchain, UINT x1, UINT x2);
 	if (is_capture)
 		dx11_capture(thiz);
@@ -507,7 +510,8 @@ HRESULT __stdcall dx11_hkPresent(IDXGISwapChain* thiz, UINT SyncInterval, UINT F
 
 //-----------------------opengl-----------------------------
 //screen capture
-long gl_capture() {
+long gl_capture()
+{
 	using glPixelStorei_t = decltype(glPixelStorei)*;
 	using glReadBuffer_t = decltype(glReadBuffer)*;
 	using glGetIntegerv_t = decltype(glGetIntegerv)*;
@@ -538,8 +542,8 @@ long gl_capture() {
 	if (mem.open(DisplayHook::shared_res_name) && mutex.open(DisplayHook::mutex_name)) {
 		mutex.lock();
 		uchar* pshare = mem.data<byte>();
-		formatFrameInfo(pshare,DisplayHook::render_hwnd, width, height);
-		pglReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pshare+ sizeof(FrameInfo));
+		formatFrameInfo(pshare, DisplayHook::render_hwnd, width, height);
+		pglReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pshare + sizeof(FrameInfo));
 		mutex.unlock();
 	}
 	else {
@@ -552,9 +556,10 @@ long gl_capture() {
 	//setlog("gl screen ok");
 	return 0;
 }
-// hook glBegin or wglSwapLayerBuffers
 
-void __stdcall gl_hkglBegin(GLenum mode) {
+// hook glBegin or wglSwapLayerBuffers
+void __stdcall gl_hkglBegin(GLenum mode) 
+{
 	static DWORD t = 0;
 	using glBegin_t = decltype(glBegin)*;
 
@@ -563,22 +568,18 @@ void __stdcall gl_hkglBegin(GLenum mode) {
 	((glBegin_t)DisplayHook::old_address)(mode);
 }
 
-void __stdcall gl_hkwglSwapBuffers(HDC hdc) {
+void __stdcall gl_hkwglSwapBuffers(HDC hdc) 
+{
 	using wglSwapBuffers_t = void(__stdcall*) (HDC hdc);
 	if (is_capture)
 		gl_capture();
 	((wglSwapBuffers_t)DisplayHook::old_address)(hdc);
-	
 }
 
-
-
-
-
-
 //---------------------OPENGL ES------------------------------
 //es 类似 opengl 截图,只是模块不同
-long egl_capture() {
+long egl_capture() 
+{
 	using glPixelStorei_t = decltype(glPixelStorei)*;
 	using glReadBuffer_t = decltype(glReadBuffer)*;
 	using glGetIntegerv_t = decltype(glGetIntegerv)*;
@@ -609,7 +610,7 @@ long egl_capture() {
 	if (mem.open(DisplayHook::shared_res_name) && mutex.open(DisplayHook::mutex_name)) {
 		mutex.lock();
 		uchar* pshare = mem.data<byte>();
-		formatFrameInfo(pshare,DisplayHook::render_hwnd, width, height);
+		formatFrameInfo(pshare, DisplayHook::render_hwnd, width, height);
 		pglReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pshare + sizeof(FrameInfo));
 		//pglReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, mem.data<byte>());
 		mutex.unlock();
@@ -625,16 +626,16 @@ long egl_capture() {
 	return 0;
 }
 
-unsigned int __stdcall gl_hkeglSwapBuffers(void* dpy, void* surface) {
+unsigned int __stdcall gl_hkeglSwapBuffers(void* dpy, void* surface)
+{
 	using eglSwapBuffers_t = decltype(gl_hkeglSwapBuffers)*;
 	if (is_capture)
 		egl_capture();
 	return ((eglSwapBuffers_t)DisplayHook::old_address)(dpy, surface);
-	
 }
 
-
-void __stdcall gl_hkglFinish(void) {
+void __stdcall gl_hkglFinish(void) 
+{
 	using glFinish_t = decltype(glFinish)*;
 	if (is_capture)
 		gl_capture();

+ 2 - 2
gm/gm/background/Hook/DisplayHook.h

@@ -12,8 +12,8 @@ public:
 	/*name of ...*/
 	static wchar_t shared_res_name[256];
 	static wchar_t mutex_name[256];
-	static void *old_address;
-	static bool is_hooked ;
+	static void* old_address;
+	static bool is_hooked;
 	//
 	static int setup(HWND hwnd_, int render_type_);
 	static int release();

+ 44 - 44
gm/gm/background/Hook/HookExport.cpp

@@ -2,64 +2,64 @@
 #include "DisplayHook.h"
 #include "InputHook.h"
 #include "../../core/opEnv.h"
+
 int refCount = 0;
 //--------------export function--------------------------
 long __stdcall SetDisplayHook(HWND hwnd_, int render_type_)
 {
-    int ret = 0;
-    opEnv::m_showErrorMsg = 2; //this code is excuate in hookde process,so its better not show meesageBox(avoid suspend the work thread)
-    if (!DisplayHook::is_hooked)
-    {
-      ret  = DisplayHook::setup(hwnd_, render_type_);
-      DisplayHook::is_hooked = ret == 1;
-      refCount += DisplayHook::is_hooked;
-    }
-    else {
-        //setlog("warning: ")
-        ret = 1;
-    }
-    return ret;
+	int ret = 0;
+	opEnv::m_showErrorMsg = 2; //this code is excuate in hookde process,so its better not show meesageBox(avoid suspend the work thread)
+	if (!DisplayHook::is_hooked)
+	{
+		ret = DisplayHook::setup(hwnd_, render_type_);
+		DisplayHook::is_hooked = ret == 1;
+		refCount += DisplayHook::is_hooked;
+	}
+	else {
+		//setlog("warning: ")
+		ret = 1;
+	}
+	return ret;
 }
 
 long __stdcall ReleaseDisplayHook()
 {
-    int ret = 0;
-    if (DisplayHook::is_hooked){
-        DisplayHook::is_hooked = false;
-        ret = DisplayHook::release();
-        refCount--;
-        if(refCount==0){
-            ::FreeLibraryAndExitThread(static_cast<HMODULE>(opEnv::getInstance()), 0);
-        }
-        
-    }
-  
-  
-    return ret;
+	int ret = 0;
+	if (DisplayHook::is_hooked) {
+		DisplayHook::is_hooked = false;
+		ret = DisplayHook::release();
+		refCount--;
+		if (refCount == 0) {
+			::FreeLibraryAndExitThread(static_cast<HMODULE>(opEnv::getInstance()), 0);
+		}
+
+	}
+
+	return ret;
 }
 
 long __stdcall SetInputHook(HWND hwnd_, int input_type_)
 {
-    int ret = 0;
-    if (!InputHook::is_hooked)
-    {
-        ret = InputHook::setup(hwnd_, input_type_);
-        InputHook::is_hooked = ret == 1;
-         refCount += InputHook::is_hooked;
-    }
-    return ret;
+	int ret = 0;
+	if (!InputHook::is_hooked)
+	{
+		ret = InputHook::setup(hwnd_, input_type_);
+		InputHook::is_hooked = ret == 1;
+		refCount += InputHook::is_hooked;
+	}
+	return ret;
 }
 
 long __stdcall ReleaseInputHook()
 {
-    if (InputHook::is_hooked)
-    {
-        InputHook::release();
-        InputHook::is_hooked = false;
-         refCount--;
-        if(refCount==0){
-            ::FreeLibraryAndExitThread(static_cast<HMODULE>(opEnv::getInstance()), 0);
-        }
-    }
-    return 1;
+	if (InputHook::is_hooked)
+	{
+		InputHook::release();
+		InputHook::is_hooked = false;
+		refCount--;
+		if (refCount == 0) {
+			::FreeLibraryAndExitThread(static_cast<HMODULE>(opEnv::getInstance()), 0);
+		}
+	}
+	return 1;
 }

+ 0 - 1
gm/gm/background/Hook/HookExport.h

@@ -1,6 +1,5 @@
 #include "../../core/globalVar.h"
 
-
 //描述: 设置显示Hook
 //返回值:1 成功,0失败
 DLL_API long __stdcall SetDisplayHook(HWND hwnd_, int render_type_);

+ 190 - 193
gm/gm/background/Hook/InputHook.cpp

@@ -5,26 +5,25 @@
 #include "opMessage.h"
 #include "../../winapi/query_api.h"
 #include "MinHook.h"
-
 #include "dinput.h"
 #include <vector>
 
-const GUID OP_IID_IDirectInput8W = {0xBF798031, 0x483A, 0x4DA2, 0xAA, 0x99, 0x5D, 0x64, 0xED, 0x36, 0x97, 0x00};
-const GUID OP_GUID_SysMouse = {0x6F1D2B60, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00};
+const GUID OP_IID_IDirectInput8W = { 0xBF798031, 0x483A, 0x4DA2, 0xAA, 0x99, 0x5D, 0x64, 0xED, 0x36, 0x97, 0x00 };
+const GUID OP_GUID_SysMouse = { 0x6F1D2B60, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 };
 /*target window hwnd*/
 HWND InputHook::input_hwnd;
 int InputHook::input_type;
 /*name of ...*/
 wchar_t InputHook::shared_res_name[256];
 wchar_t InputHook::mutex_name[256];
-void *InputHook::old_address;
+void* InputHook::old_address;
 //
 opMouseState InputHook::m_mouseState;
 bool InputHook::is_hooked = false;
 
 WNDPROC gRawWindowProc = 0;
-std::vector<void *> gDinputVtb;
-std::vector<void *> gDinputVtbRaw;
+std::vector<void*> gDinputVtb;
+std::vector<void*> gDinputVtbRaw;
 
 const int indexAcquire = 7;
 const int indexGetDeviceState = 9;
@@ -32,232 +31,230 @@ const int indexPoll = 25;
 
 int getDinputVtb();
 
-HRESULT __stdcall hkAcquire(IDirectInputDevice8W *this_);
-
-HRESULT __stdcall hkPoll(IDirectInputDevice8W *this_);
-
-HRESULT __stdcall hkGetDeviceState(IDirectInputDevice8W *this_, DWORD size, LPVOID ptr);
-
+HRESULT __stdcall hkAcquire(IDirectInputDevice8W* this_);
+HRESULT __stdcall hkPoll(IDirectInputDevice8W* this_);
+HRESULT __stdcall hkGetDeviceState(IDirectInputDevice8W* this_, DWORD size, LPVOID ptr);
 LRESULT CALLBACK opWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
 
 int InputHook::setup(HWND hwnd_, int input_type_)
 {
-    if (!IsWindow(hwnd_))
-        return 0;
-    opEnv::m_showErrorMsg = 2; //write data to file
-    setlog("SetInputHook");
-    if (getDinputVtb() == 1)
-    {
-        MH_Initialize();
-        MH_CreateHook(
-            gDinputVtb[indexGetDeviceState],
-            hkGetDeviceState,
-            &gDinputVtbRaw[indexGetDeviceState]);
-        MH_CreateHook(
-            gDinputVtb[indexPoll],
-            hkPoll,
-            &gDinputVtbRaw[indexPoll]);
-        MH_EnableHook(NULL);
-        gRawWindowProc = reinterpret_cast<WNDPROC>(SetWindowLongPtrA(hwnd_, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(opWndProc)));
-        InputHook::input_hwnd = hwnd_;
-    }
-    else
-    {
-        setlog("getDinputVtb false!");
-    }
+	if (!IsWindow(hwnd_))
+		return 0;
+	opEnv::m_showErrorMsg = 2; //write data to file
+	setlog("SetInputHook");
+	if (getDinputVtb() == 1)
+	{
+		MH_Initialize();
+		MH_CreateHook(
+			gDinputVtb[indexGetDeviceState],
+			hkGetDeviceState,
+			&gDinputVtbRaw[indexGetDeviceState]);
+		MH_CreateHook(
+			gDinputVtb[indexPoll],
+			hkPoll,
+			&gDinputVtbRaw[indexPoll]);
+		MH_EnableHook(NULL);
+		gRawWindowProc = reinterpret_cast<WNDPROC>(SetWindowLongPtrA(hwnd_, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(opWndProc)));
+		InputHook::input_hwnd = hwnd_;
+	}
+	else
+	{
+		setlog("getDinputVtb false!");
+	}
 
-    return gRawWindowProc ? 1 : -1;
+	return gRawWindowProc ? 1 : -1;
 }
+
 int InputHook::release()
 {
-    LONG_PTR ptr = 0;
-    if (gRawWindowProc)
-    {
-        MH_RemoveHook(NULL);
-        MH_Uninitialize();
-        ptr = SetWindowLongPtrA(InputHook::input_hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(gRawWindowProc));
-    }
-    return ptr ? 1 : 0;
-    return 0;
+	LONG_PTR ptr = 0;
+	if (gRawWindowProc)
+	{
+		MH_RemoveHook(NULL);
+		MH_Uninitialize();
+		ptr = SetWindowLongPtrA(InputHook::input_hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(gRawWindowProc));
+	}
+	return ptr ? 1 : 0;
+	return 0;
 }
 
 void InputHook::upDataPos(LPARAM lp, int key, bool down)
 {
-    m_mouseState.lAxisX = lp & 0xffff;
-    m_mouseState.lAxisY = (lp >> 16) & 0xffff;
-    setlog("upDataPos x=%d, y=%d", m_mouseState.lAxisX, m_mouseState.lAxisY);
-    if (0 <= key && key < 3)
-    {
-        m_mouseState.abButtons[key] = down ? 0x80 : 0;
-    }
+	m_mouseState.lAxisX = lp & 0xffff;
+	m_mouseState.lAxisY = (lp >> 16) & 0xffff;
+	setlog("upDataPos x=%d, y=%d", m_mouseState.lAxisX, m_mouseState.lAxisY);
+	if (0 <= key && key < 3)
+	{
+		m_mouseState.abButtons[key] = down ? 0x80 : 0;
+	}
 }
 
 int getDinputVtb()
 {
-    using DirectInput8Create_t = decltype(DirectInput8Create);
-    auto pDirectInput8Create = reinterpret_cast<DirectInput8Create_t *>(query_api("dinput8.dll", "DirectInput8Create"));
-    if (pDirectInput8Create)
-    {
-        WNDCLASSEX windowClass;
-        windowClass.cbSize = sizeof(WNDCLASSEX);
-        windowClass.style = CS_HREDRAW | CS_VREDRAW;
-        windowClass.lpfnWndProc = DefWindowProc;
-        windowClass.cbClsExtra = 0;
-        windowClass.cbWndExtra = 0;
-        windowClass.hInstance = GetModuleHandle(NULL);
-        windowClass.hIcon = NULL;
-        windowClass.hCursor = NULL;
-        windowClass.hbrBackground = NULL;
-        windowClass.lpszMenuName = NULL;
-        windowClass.lpszClassName = L"Kiero";
-        windowClass.hIconSm = NULL;
+	using DirectInput8Create_t = decltype(DirectInput8Create);
+	auto pDirectInput8Create = reinterpret_cast<DirectInput8Create_t*>(query_api("dinput8.dll", "DirectInput8Create"));
+	if (pDirectInput8Create)
+	{
+		WNDCLASSEX windowClass;
+		windowClass.cbSize = sizeof(WNDCLASSEX);
+		windowClass.style = CS_HREDRAW | CS_VREDRAW;
+		windowClass.lpfnWndProc = DefWindowProc;
+		windowClass.cbClsExtra = 0;
+		windowClass.cbWndExtra = 0;
+		windowClass.hInstance = GetModuleHandle(NULL);
+		windowClass.hIcon = NULL;
+		windowClass.hCursor = NULL;
+		windowClass.hbrBackground = NULL;
+		windowClass.lpszMenuName = NULL;
+		windowClass.lpszClassName = L"Kiero";
+		windowClass.hIconSm = NULL;
 
-        ::RegisterClassEx(&windowClass);
+		::RegisterClassEx(&windowClass);
 
-        HWND window = ::CreateWindowW(windowClass.lpszClassName, L"Kiero DirectX Window", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, NULL, NULL, windowClass.hInstance, NULL);
-        LPDIRECTINPUT8 pDinput = NULL;
+		HWND window = ::CreateWindowW(windowClass.lpszClassName, L"Kiero DirectX Window", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, NULL, NULL, windowClass.hInstance, NULL);
+		LPDIRECTINPUT8 pDinput = NULL;
 
-        if (pDirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION,
-                                OP_IID_IDirectInput8W, (VOID **)&pDinput, NULL) < 0)
-        {
-            ::DestroyWindow(window);
-            ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
-            setlog("pDirectInput8Create false!");
-            return -1;
-        }
+		if (pDirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION,
+			OP_IID_IDirectInput8W, (VOID**)&pDinput, NULL) < 0)
+		{
+			::DestroyWindow(window);
+			::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
+			setlog("pDirectInput8Create false!");
+			return -1;
+		}
 
-        LPDIRECTINPUTDEVICE8 pMouse = NULL;
-        if (pDinput->CreateDevice(OP_GUID_SysMouse, &pMouse, NULL) < 0)
-        {
-            ::DestroyWindow(window);
-            ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
-            setlog("CreateDevice false!");
-            return -2;
-        }
-        gDinputVtb.resize(32);
-        gDinputVtbRaw.resize(32);
-        ::memcpy(&gDinputVtb[0], *(size_t **)pMouse, 32 * sizeof(size_t));
+		LPDIRECTINPUTDEVICE8 pMouse = NULL;
+		if (pDinput->CreateDevice(OP_GUID_SysMouse, &pMouse, NULL) < 0)
+		{
+			::DestroyWindow(window);
+			::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
+			setlog("CreateDevice false!");
+			return -2;
+		}
+		gDinputVtb.resize(32);
+		gDinputVtbRaw.resize(32);
+		::memcpy(&gDinputVtb[0], *(size_t**)pMouse, 32 * sizeof(size_t));
 
-        ::DestroyWindow(window);
-        ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
+		::DestroyWindow(window);
+		::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
 
-        return 1;
-        //MH_Initialize();
-    }
-    else
-    {
-        setlog("dinput8 not found");
-        return 0;
-    }
+		return 1;
+		//MH_Initialize();
+	}
+	else
+	{
+		setlog("dinput8 not found");
+		return 0;
+	}
 }
 
-HRESULT __stdcall hkAcquire(IDirectInputDevice8W *this_)
+HRESULT __stdcall hkAcquire(IDirectInputDevice8W* this_)
 {
-    return DI_OK;
+	return DI_OK;
 }
 
-HRESULT __stdcall hkPoll(IDirectInputDevice8W *this_)
+HRESULT __stdcall hkPoll(IDirectInputDevice8W* this_)
 {
-    return DI_OK;
+	return DI_OK;
 }
 
-void EndianSwap(char *pData, int startIndex, int length)
+void EndianSwap(char* pData, int startIndex, int length)
 {
-    int i,cnt,end,start;
-    cnt = length / 2;
-    start = startIndex;
-    end  = startIndex + length - 1;
-    char tmp;
-    for (i = 0; i < cnt; i++)
-    {
-        tmp            = pData[start+i];
-        pData[start+i] = pData[end-i];
-        pData[end-i]   = tmp;
-    }
+	int i, cnt, end, start;
+	cnt = length / 2;
+	start = startIndex;
+	end = startIndex + length - 1;
+	char tmp;
+	for (i = 0; i < cnt; i++)
+	{
+		tmp = pData[start + i];
+		pData[start + i] = pData[end - i];
+		pData[end - i] = tmp;
+	}
 }
 
-HRESULT __stdcall hkGetDeviceState(IDirectInputDevice8W *this_, DWORD size, LPVOID ptr)
+HRESULT __stdcall hkGetDeviceState(IDirectInputDevice8W* this_, DWORD size, LPVOID ptr)
 {
-    //setlog("called hkGetDeviceState");
-    using GetDeviceState_t = decltype(hkGetDeviceState);
+	//setlog("called hkGetDeviceState");
+	using GetDeviceState_t = decltype(hkGetDeviceState);
 
-    if (size == sizeof(opMouseState))
-    {
-        opMouseState state = {};
-        //setlog("called opMouseState");
-        // state.lAxisX = InputHook::m_mouseState.lAxisX;
-        // state.lAxisY = InputHook::m_mouseState.lAxisY;
-        // state.abButtons[0]
-        state = InputHook::m_mouseState;
-        //EndianSwap((char*)&state,0, sizeof(state));
-        memcpy(ptr, &state, sizeof(state));
-        return DI_OK;
-    }
-    else if (size == sizeof(DIMOUSESTATE))
-    {
-        DIMOUSESTATE state = {};
-        setlog("called DIMOUSESTATE");
+	if (size == sizeof(opMouseState))
+	{
+		opMouseState state = {};
+		//setlog("called opMouseState");
+		// state.lAxisX = InputHook::m_mouseState.lAxisX;
+		// state.lAxisY = InputHook::m_mouseState.lAxisY;
+		// state.abButtons[0]
+		state = InputHook::m_mouseState;
+		//EndianSwap((char*)&state,0, sizeof(state));
+		memcpy(ptr, &state, sizeof(state));
+		return DI_OK;
+	}
+	else if (size == sizeof(DIMOUSESTATE))
+	{
+		DIMOUSESTATE state = {};
+		setlog("called DIMOUSESTATE");
 
-        state.lX = InputHook::m_mouseState.lAxisX;
-        state.lY = InputHook::m_mouseState.lAxisY;
+		state.lX = InputHook::m_mouseState.lAxisX;
+		state.lY = InputHook::m_mouseState.lAxisY;
 
-        memcpy(ptr, &state, sizeof(state));
-        return DI_OK;
-    }
-    else if (size == sizeof(DIMOUSESTATE2))
-    {
-        DIMOUSESTATE2 state = {};
-        setlog("called DIMOUSESTATE2");
-        state.lX = InputHook::m_mouseState.lAxisX;
-        state.lY = InputHook::m_mouseState.lAxisY;
-        memcpy(ptr, &state, sizeof(state));
-        return DI_OK;
-    }
-    else
-    {
-        return reinterpret_cast<GetDeviceState_t *>(gDinputVtbRaw[indexGetDeviceState])(this_, size, ptr);
-    }
+		memcpy(ptr, &state, sizeof(state));
+		return DI_OK;
+	}
+	else if (size == sizeof(DIMOUSESTATE2))
+	{
+		DIMOUSESTATE2 state = {};
+		setlog("called DIMOUSESTATE2");
+		state.lX = InputHook::m_mouseState.lAxisX;
+		state.lY = InputHook::m_mouseState.lAxisY;
+		memcpy(ptr, &state, sizeof(state));
+		return DI_OK;
+	}
+	else
+	{
+		return reinterpret_cast<GetDeviceState_t*>(gDinputVtbRaw[indexGetDeviceState])(this_, size, ptr);
+	}
 }
 
 LRESULT CALLBACK opWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
-    setlog("%04X message", message);
-    switch (message)
-    {
-    case OP_WM_MOUSEMOVE:
-    {
-        InputHook::upDataPos(lParam, -1, false);
-        setlog("OP_WM_MOUSEMOVE message");
-        break;
-    }
-    case OP_WM_LBUTTONUP:
-        InputHook::upDataPos(lParam, 0, false);
-        setlog("OP_WM_LBUTTONUP message");
-        break;
-    case OP_WM_LBUTTONDOWN:
-        InputHook::upDataPos(lParam, 0, true);
-        setlog("OP_WM_LBUTTONDOWN message");
-        break;
-    case OP_WM_MBUTTONDOWN:
-        InputHook::upDataPos(lParam, 1, true);
-        setlog("OP_WM_MBUTTONDOWN message");
-        break;
-    case OP_WM_MBUTTONUP:
-        InputHook::upDataPos(lParam, 1, false);
-        setlog("OP_WM_MBUTTONUP message");
-        break;
-    case OP_WM_RBUTTONDOWN:
-        InputHook::upDataPos(lParam, 2, true);
-        setlog("OP_WM_RBUTTONDOWN message");
-        break;
-    case OP_WM_RBUTTONUP:
-        InputHook::upDataPos(lParam, 2, false);
-        setlog("OP_WM_RBUTTONUP message");
-        break;
-    case OP_WM_MOUSEWHEEL:
-        //InputHook::upDataPos(wParam,2,true);
-        setlog("OP_WM_MOUSEWHEEL message");
-        break;
-    }
-    return CallWindowProcA(gRawWindowProc, InputHook::input_hwnd, message, wParam, lParam);
+	setlog("%04X message", message);
+	switch (message)
+	{
+		case OP_WM_MOUSEMOVE:
+			{
+				InputHook::upDataPos(lParam, -1, false);
+				setlog("OP_WM_MOUSEMOVE message");
+				break;
+			}
+		case OP_WM_LBUTTONUP:
+			InputHook::upDataPos(lParam, 0, false);
+			setlog("OP_WM_LBUTTONUP message");
+			break;
+		case OP_WM_LBUTTONDOWN:
+			InputHook::upDataPos(lParam, 0, true);
+			setlog("OP_WM_LBUTTONDOWN message");
+			break;
+		case OP_WM_MBUTTONDOWN:
+			InputHook::upDataPos(lParam, 1, true);
+			setlog("OP_WM_MBUTTONDOWN message");
+			break;
+		case OP_WM_MBUTTONUP:
+			InputHook::upDataPos(lParam, 1, false);
+			setlog("OP_WM_MBUTTONUP message");
+			break;
+		case OP_WM_RBUTTONDOWN:
+			InputHook::upDataPos(lParam, 2, true);
+			setlog("OP_WM_RBUTTONDOWN message");
+			break;
+		case OP_WM_RBUTTONUP:
+			InputHook::upDataPos(lParam, 2, false);
+			setlog("OP_WM_RBUTTONUP message");
+			break;
+		case OP_WM_MOUSEWHEEL:
+			//InputHook::upDataPos(wParam,2,true);
+			setlog("OP_WM_MOUSEWHEEL message");
+			break;
+	}
+	return CallWindowProcA(gRawWindowProc, InputHook::input_hwnd, message, wParam, lParam);
 }

+ 1 - 1
gm/gm/background/Hook/InputHook.h

@@ -20,7 +20,7 @@ public:
 	/*name of ...*/
 	static wchar_t shared_res_name[256];
 	static wchar_t mutex_name[256];
-	static void *old_address;
+	static void* old_address;
 	static bool is_hooked;
 	//
 	static int setup(HWND hwnd_, int input_type_);

+ 12 - 9
gm/gm/background/display/IDisplay.cpp

@@ -2,6 +2,7 @@
 #include "IDisplay.h"
 #include "./core/globalVar.h"
 #include "./core/helpfunc.h"
+
 IDisplay::IDisplay()
 	:_hwnd(NULL), _shmem(nullptr), _pmutex(nullptr),
 	_bind_state(0), _width(0), _height(0),
@@ -10,14 +11,14 @@ IDisplay::IDisplay()
 
 }
 
-
 IDisplay::~IDisplay()
 {
 	bind_release();
 	_bind_state = 0;
 }
 
-long IDisplay::Bind(HWND hwnd, long flag) {
+long IDisplay::Bind(HWND hwnd, long flag)
+{
 	//step 1 check window exists
 	if (!::IsWindow(hwnd)) {
 		return 0;
@@ -34,13 +35,12 @@ long IDisplay::Bind(HWND hwnd, long flag) {
 		bind_release();
 		_bind_state = 0;
 	}
-		
 
 	return _bind_state;
-
 }
 
-long IDisplay::UnBind() {
+long IDisplay::UnBind() 
+{
 	//setlog("UnBind(");
 	if (_bind_state) {
 		UnBindEx();
@@ -50,12 +50,13 @@ long IDisplay::UnBind() {
 	return 1;
 }
 
-long IDisplay::bind_init() {
+long IDisplay::bind_init() 
+{
 	int res_size = 0;
 	RECT rc;
 	assert(::IsWindow(_hwnd));
 	::GetWindowRect(_hwnd, &rc);
-	res_size = (rc.right - rc.left) * (rc.bottom - rc.top) * 4+sizeof(FrameInfo);
+	res_size = (rc.right - rc.left) * (rc.bottom - rc.top) * 4 + sizeof(FrameInfo);
 	wsprintf(_shared_res_name, SHARED_RES_NAME_FORMAT, _hwnd);
 	wsprintf(_mutex_name, MUTEX_NAME_FORMAT, _hwnd);
 	//setlog(L"mem=%s mutex=%s", _shared_res_name, _mutex_name);
@@ -73,7 +74,8 @@ long IDisplay::bind_init() {
 	return 0;
 }
 
-long IDisplay::bind_release() {
+long IDisplay::bind_release()
+{
 	SAFE_DELETE(_shmem);
 	SAFE_DELETE(_pmutex);
 
@@ -82,7 +84,8 @@ long IDisplay::bind_release() {
 	return 0;
 }
 
-void IDisplay::getFrameInfo(FrameInfo& info) {
+void IDisplay::getFrameInfo(FrameInfo& info) 
+{
 	_pmutex->lock();
 	memcpy(&info, _shmem->data<uchar>(), sizeof(FrameInfo));
 	_pmutex->unlock();

+ 6 - 13
gm/gm/background/display/IDisplay.h

@@ -1,15 +1,17 @@
 #ifndef __IDISPLAY_H_
 #define __IDISPLAY_H_
+
 #include <exception>
 #include "./include/promutex.h"
 #include "./include/sharedmem.h"
 #include "frameInfo.h"
+
 struct Image;
 class IDisplay
 {
 public:
 	IDisplay();
-	 ~IDisplay();
+	~IDisplay();
 	//bind window
 	long Bind(HWND hwnd, long flag);
 	//unbind window
@@ -17,7 +19,6 @@ public:
 	//unbind window
 	//virtual long UnBind(HWND hwnd) = 0;
 	virtual bool requestCapture(int x1, int y1, int w, int h, Image& img) = 0;
-	
 
 	promutex* get_mutex() {
 		return _pmutex;
@@ -31,37 +32,29 @@ public:
 		return _width;
 	}
 	void getFrameInfo(FrameInfo& info);
+
 private:
-	
 	long bind_init();
-	
 	long bind_release();
-
 	long _bind_state;
+
 protected:
-	virtual long BindEx(HWND hwnd, long flag)=0;
+	virtual long BindEx(HWND hwnd, long flag) = 0;
 	virtual long UnBindEx() = 0;
 
 	HWND _hwnd;
-
 	sharedmem* _shmem;
-	
 	promutex* _pmutex;
-
 	wchar_t _shared_res_name[256];
-
 	wchar_t _mutex_name[256];
 
 	//
 	int _render_type;
-
 	long _width;
 	long _height;
-
 	int _client_x, _client_y;
 	//need capture rect
 	//RECT rect;
-	
 };
 
 #endif

+ 2 - 1
gm/gm/background/display/frameInfo.h

@@ -1,5 +1,6 @@
 #ifndef __FRAME_INFO_H_
 #define __FRAME_INFO_H_
+
 #pragma pack(1)
 struct FrameInfo {
 	unsigned __int64 hwnd;
@@ -11,7 +12,7 @@ struct FrameInfo {
 	void fmtChk() {
 		chk = (hwnd >> 32) ^ (hwnd & 0xffffffffull) ^ frameId ^ time ^ width ^ height;
 	}
-	
 };
 #pragma pack()
+
 #endif // !__FRAME_INFO_H_

+ 15 - 41
gm/gm/background/display/opDxGL.cpp

@@ -1,6 +1,5 @@
 
 //#include "stdafx.h"
-
 #include "opDxGL.h"
 #include "./core/globalVar.h"
 #include "./core/helpfunc.h"
@@ -8,23 +7,21 @@
 #include <exception>
 #include "BlackBone/Process/Process.h"
 #include "BlackBone/Process/RPC/RemoteFunction.hpp"
-
 #include "./include/Image.hpp"
-
 #include <sstream>
-opDxGL::opDxGL() :IDisplay(),m_opPath(opEnv::getBasePath())
+
+opDxGL::opDxGL() :IDisplay(), m_opPath(opEnv::getBasePath())
 {
 }
 
-
 opDxGL::~opDxGL()
 {
 	//do clear
 	UnBindEx();
 }
 
-
-long opDxGL::BindEx(HWND hwnd, long render_type) {
+long opDxGL::BindEx(HWND hwnd, long render_type)
+{
 	//setlog("BindEx");
 	_hwnd = hwnd;
 	long bind_ret = 0;
@@ -44,15 +41,11 @@ long opDxGL::BindEx(HWND hwnd, long render_type) {
 		DWORD id;
 		::GetWindowThreadProcessId(_hwnd, &id);
 
-
-
 		//attach 进程
 		blackbone::Process proc;
 		NTSTATUS hr;
-
 		hr = proc.Attach(id);
 
-
 		if (NT_SUCCESS(hr)) {
 			wstring dllname = opEnv::getOpName();
 			//检查是否与插件相同的32/64位,如果不同,则使用另一种dll
@@ -77,7 +70,6 @@ long opDxGL::BindEx(HWND hwnd, long render_type) {
 				else {
 					setlog(L"file:<%s> not exists!", opFile.data());
 				}
-
 			}
 			if (injected) {
 				//setlog("before MakeRemoteFunction");
@@ -101,7 +93,7 @@ long opDxGL::BindEx(HWND hwnd, long render_type) {
 		else {
 			setlog(L"attach false.");
 		}
-		
+
 		proc.Detach();
 		//setlog("after Detach");
 	}
@@ -123,7 +115,8 @@ long opDxGL::BindEx(HWND hwnd, long render_type) {
 //	return UnBind();
 //}
 
-long opDxGL::UnBindEx() {
+long opDxGL::UnBindEx() 
+{
 	//setlog("bkdo::UnBindEx()");
 	if (_render_type == RDT_GL_NOX)
 		return UnBindNox();
@@ -137,7 +130,7 @@ long opDxGL::UnBindEx() {
 	hr = proc.Attach(id);
 
 	if (NT_SUCCESS(hr)) {
-		wstring dllname =  opEnv::getOpName();
+		wstring dllname = opEnv::getOpName();
 		//检查是否与插件相同的32/64位,如果不同,则使用另一种dll
 		BOOL is64 = proc.modules().GetMainModule()->type == blackbone::eModType::mt_mod64;
 		if (is64 != OP64) {
@@ -167,7 +160,8 @@ long opDxGL::UnBindEx() {
 	return 1;
 }
 
-long opDxGL::BindNox(HWND hwnd, long render_type) {
+long opDxGL::BindNox(HWND hwnd, long render_type) 
+{
 	_render_type = render_type;
 	_hwnd = hwnd;
 	RECT rc;
@@ -176,21 +170,14 @@ long opDxGL::BindNox(HWND hwnd, long render_type) {
 	_width = rc.right - rc.left;
 	_height = rc.bottom - rc.top;
 	//bind_init();
-
-
-
 	//attach 进程
 	blackbone::Process proc;
 	NTSTATUS hr = -1;
 
-
 	wstring dllname = L"op_x64.dll";
-
-
 	hr = proc.Attach(L"NoxVMHandle.exe");
 
 	long bind_ret = 0;
-
 	if (NT_SUCCESS(hr)) {
 		/*_process.Resume();*/
 		bool injected = false;
@@ -224,21 +211,17 @@ long opDxGL::BindNox(HWND hwnd, long render_type) {
 		else {
 			setlog(L"Inject false.");
 		}
-
-
-
 	}
 	else {
 		setlog(L"attach false.");
 	}
 	proc.Detach();
 
-
 	return bind_ret;
 }
 
-long opDxGL::UnBindNox() {
-
+long opDxGL::UnBindNox()
+{
 	//attach 进程
 	blackbone::Process proc;
 	NTSTATUS hr;
@@ -246,9 +229,7 @@ long opDxGL::UnBindNox() {
 	hr = proc.Attach(L"NoxVMHandle.exe");
 	wstring dllname = L"op_x64.dll";
 
-
 	if (NT_SUCCESS(hr)) {
-
 		using my_func_t = long(__stdcall*)(void);
 		auto pUnXHook = blackbone::MakeRemoteFunction<my_func_t>(proc, dllname, "ReleaseDisplayHook");
 		if (pUnXHook) {
@@ -270,38 +251,31 @@ long opDxGL::UnBindNox() {
 	return 1;
 }
 
-
-
-bool opDxGL::requestCapture(int x1, int y1, int w, int h, Image& img) {
+bool opDxGL::requestCapture(int x1, int y1, int w, int h, Image& img)
+{
 	img.create(w, h);
 	_pmutex->lock();
 	uchar* const ppixels = _shmem->data<byte>() + sizeof(FrameInfo);
 	FrameInfo* pInfo = (FrameInfo*)_shmem->data<byte>();
 	static bool first = true;
-	if (first&&(pInfo->width != _width || pInfo->height != _height)) {
+	if (first && (pInfo->width != _width || pInfo->height != _height)) {
 		first = false;
 		std::wstringstream ss(std::wstringstream::in | std::wstringstream::out);
 		ss << (*pInfo);
 		setlog(L"error pInfo->width != _width || pInfo->height != _height\nframe info:\n%s", ss.str().data());
-	
 	}
 
-
 	if (GET_RENDER_TYPE(_render_type) == RENDER_TYPE::DX) {//NORMAL
-
 		for (int i = 0; i < h; i++) {
 			memcpy(img.ptr<uchar>(i), ppixels + (i + y1) * 4 * _width + x1 * 4, 4 * w);
 		}
 	}
 	else {
-
 		for (int i = 0; i < h; i++) {
 			memcpy(img.ptr<uchar>(i), ppixels + (_height - 1 - i - y1) * _width * 4 + x1 * 4, 4 * w);
 		}
 	}
 
-
 	_pmutex->unlock();
 	return true;
 }
-

+ 2 - 3
gm/gm/background/display/opDxGL.h

@@ -4,6 +4,7 @@
 
 #include "IDisplay.h"
 struct Image;
+
 class opDxGL : public IDisplay
 {
 public:
@@ -11,12 +12,10 @@ public:
 	~opDxGL();
 	//1
 	long BindEx(HWND hwnd, long render_type) override;
-
 	/*long UnBind(HWND hwnd);*/
 
 	long UnBindEx() override;
-
-	virtual bool requestCapture(int x1, int y1, int w, int h, Image &img) override;
+	virtual bool requestCapture(int x1, int y1, int w, int h, Image& img) override;
 
 	//nox mode
 	long BindNox(HWND hwnd, long render_type);

+ 248 - 234
gm/gm/background/display/opGDI.cpp

@@ -1,252 +1,266 @@
 //#include "stdafx.h"
 #include "opGDI.h"
-
 #include <atlimage.h>
-
 #include <fstream>
-
 #include "../../winapi/WinApi.h"
 #include "./include/Image.hpp"
 #include "globalVar.h"
 #include "helpfunc.h"
-opGDI::opGDI() {
-  _render_type = 0;
-  dx_ = 0;
-  dy_ = 0;
-  // 4*2^22=16*2^20=16MB
-  //_image_data = new byte[MAX_IMAGE_WIDTH*MAX_IMAGE_WIDTH * 4];
+
+opGDI::opGDI() 
+{
+	_render_type = 0;
+	dx_ = 0;
+	dy_ = 0;
+	// 4*2^22=16*2^20=16MB
+	//_image_data = new byte[MAX_IMAGE_WIDTH*MAX_IMAGE_WIDTH * 4];
 }
 
-opGDI::~opGDI() {
-  // SAFE_DELETE_ARRAY(_image_data);
+opGDI::~opGDI() 
+{
+	// SAFE_DELETE_ARRAY(_image_data);
 }
 
-long opGDI::BindEx(HWND hwnd, long render_type) {
-  if (!::IsWindow(hwnd)) return 0;
-  _hwnd = hwnd;
-  _render_type = render_type;
-
-  if (render_type == RDT_NORMAL) {
-    RECT rc, rc2;
-    ::GetWindowRect(_hwnd, &rc);
-    ::GetClientRect(hwnd, &rc2);
-
-    _width = rc2.right - rc2.left;
-    _height = rc2.bottom - rc2.top;
-    POINT pt = {0};
-    ::ClientToScreen(hwnd, &pt);
-    dx_ = pt.x - rc.left;
-    dy_ = pt.y - rc.top;
-    _hdc = ::GetDC(NULL);
-  } else {  // client size
-    RECT rc, rc2;
-    ::GetWindowRect(_hwnd, &rc);
-    ::GetClientRect(hwnd, &rc2);
-    _width = rc2.right - rc2.left;
-    _height = rc2.bottom - rc2.top;
-    POINT pt = {0};
-    ::ClientToScreen(hwnd, &pt);
-    dx_ = pt.x - rc.left;
-    dy_ = pt.y - rc.top;
-    /*setlog("dx=%d dy=%d", dx_, dy_);*/
-    if (_render_type == RDT_GDI) {
-      _hdc = ::GetDC(_hwnd);
-      HWND topHwnd = WinApi::GetTopWindowSp(_hwnd);
-      long dwExStyle = 0;
-      if (GetPropA(topHwnd, "opstyle_flag")) {
-        dwExStyle = GetWindowLongA(topHwnd, GWL_EXSTYLE);
-      } else {
-        dwExStyle = GetWindowLongA(topHwnd, GWL_EXSTYLE);
-        SetPropA(topHwnd, "opstyle", (HANDLE)dwExStyle);
-        SetPropA(topHwnd, "opstyle_flag", (HANDLE)HANDLE_FLAG_INHERIT);
-      }
-      // dmIsWindowTransParent((int)InfoStruct, (int)topHwnd, (int)&v44,
-      // (int)&v42, (int)&v45);
-      SetWindowLongA(topHwnd, GWL_EXSTYLE, dwExStyle | WS_EX_LAYERED);
-      // SetWindowTransparent((int)InfoStruct, (int)topHwnd, 16711935, 0, 1);
-      UpdateWindow(topHwnd);
-
-    } else if (RDT_GDI_DX2 == render_type) {
-      _hdc = ::GetDC(_hwnd);
-      _device_caps = GetDeviceCaps(_hdc, BITSPIXEL);
-    } else {
-      HWND dx2TopHwnd = WinApi::GetTopWindowSp(_hwnd);
-      GetPropA(dx2TopHwnd, "opstyle");
-      long dx2ExStyle = 0;
-      if (GetPropA(dx2TopHwnd, "opstyle_flag")) {
-        dx2ExStyle = GetWindowLongA(dx2TopHwnd, GWL_EXSTYLE);
-      } else {
-        dx2ExStyle = GetWindowLongA(dx2TopHwnd, GWL_EXSTYLE);
-        SetPropA(dx2TopHwnd, "opstyle", (HANDLE)dx2ExStyle);
-        SetPropA(dx2TopHwnd, "opstyle_flag", (HANDLE)HANDLE_FLAG_INHERIT);
-      }
-      // dmIsWindowTransParent((int)InfoStruct, (int)dx2TopHwnd, (int)&v45,
-      // (int)&v42, (int)&v44);
-      SetWindowLongA(dx2TopHwnd, GWL_EXSTYLE, dx2ExStyle | WS_EX_LAYERED);
-      // SetWindowTransparent((int)InfoStruct, (int)dx2TopHwnd, 0, 255, 2);
-      UpdateWindow(dx2TopHwnd);
-      // InfoStruct[11] = 3;
-
-      _hdc = ::GetDC(_hwnd);
-    }
-  }
-
-  if (_hdc == NULL) {
-    setlog("hdc == NULL", _hdc);
-    return 0;
-  }
-
-  //创建一个与指定设备兼容的内存设备上下文环境
-  _hmdc = CreateCompatibleDC(_hdc);
-  if (_hmdc == NULL) {
-    setlog("CreateCompatibleDC false");
-    return -2;
-  }
-
-  // updata_screen();
-  return 1;
+long opGDI::BindEx(HWND hwnd, long render_type) 
+{
+	if (!::IsWindow(hwnd)) return 0;
+	_hwnd = hwnd;
+	_render_type = render_type;
+
+	if (render_type == RDT_NORMAL) {
+		RECT rc, rc2;
+		::GetWindowRect(_hwnd, &rc);
+		::GetClientRect(hwnd, &rc2);
+
+		_width = rc2.right - rc2.left;
+		_height = rc2.bottom - rc2.top;
+		POINT pt = { 0 };
+		::ClientToScreen(hwnd, &pt);
+		dx_ = pt.x - rc.left;
+		dy_ = pt.y - rc.top;
+		_hdc = ::GetDC(NULL);
+	}
+	else {  // client size
+		RECT rc, rc2;
+		::GetWindowRect(_hwnd, &rc);
+		::GetClientRect(hwnd, &rc2);
+		_width = rc2.right - rc2.left;
+		_height = rc2.bottom - rc2.top;
+		POINT pt = { 0 };
+		::ClientToScreen(hwnd, &pt);
+		dx_ = pt.x - rc.left;
+		dy_ = pt.y - rc.top;
+		/*setlog("dx=%d dy=%d", dx_, dy_);*/
+		if (_render_type == RDT_GDI) {
+			_hdc = ::GetDC(_hwnd);
+			HWND topHwnd = WinApi::GetTopWindowSp(_hwnd);
+			long dwExStyle = 0;
+			if (GetPropA(topHwnd, "opstyle_flag")) {
+				dwExStyle = GetWindowLongA(topHwnd, GWL_EXSTYLE);
+			}
+			else {
+				dwExStyle = GetWindowLongA(topHwnd, GWL_EXSTYLE);
+				SetPropA(topHwnd, "opstyle", (HANDLE)dwExStyle);
+				SetPropA(topHwnd, "opstyle_flag", (HANDLE)HANDLE_FLAG_INHERIT);
+			}
+			// dmIsWindowTransParent((int)InfoStruct, (int)topHwnd, (int)&v44,
+			// (int)&v42, (int)&v45);
+			SetWindowLongA(topHwnd, GWL_EXSTYLE, dwExStyle | WS_EX_LAYERED);
+			// SetWindowTransparent((int)InfoStruct, (int)topHwnd, 16711935, 0, 1);
+			UpdateWindow(topHwnd);
+
+		}
+		else if (RDT_GDI_DX2 == render_type) {
+			_hdc = ::GetDC(_hwnd);
+			_device_caps = GetDeviceCaps(_hdc, BITSPIXEL);
+		}
+		else {
+			HWND dx2TopHwnd = WinApi::GetTopWindowSp(_hwnd);
+			GetPropA(dx2TopHwnd, "opstyle");
+			long dx2ExStyle = 0;
+			if (GetPropA(dx2TopHwnd, "opstyle_flag")) {
+				dx2ExStyle = GetWindowLongA(dx2TopHwnd, GWL_EXSTYLE);
+			}
+			else {
+				dx2ExStyle = GetWindowLongA(dx2TopHwnd, GWL_EXSTYLE);
+				SetPropA(dx2TopHwnd, "opstyle", (HANDLE)dx2ExStyle);
+				SetPropA(dx2TopHwnd, "opstyle_flag", (HANDLE)HANDLE_FLAG_INHERIT);
+			}
+			// dmIsWindowTransParent((int)InfoStruct, (int)dx2TopHwnd, (int)&v45,
+			// (int)&v42, (int)&v44);
+			SetWindowLongA(dx2TopHwnd, GWL_EXSTYLE, dx2ExStyle | WS_EX_LAYERED);
+			// SetWindowTransparent((int)InfoStruct, (int)dx2TopHwnd, 0, 255, 2);
+			UpdateWindow(dx2TopHwnd);
+			// InfoStruct[11] = 3;
+
+			_hdc = ::GetDC(_hwnd);
+		}
+	}
+
+	if (_hdc == NULL) {
+		setlog("hdc == NULL", _hdc);
+		return 0;
+	}
+
+	//创建一个与指定设备兼容的内存设备上下文环境
+	_hmdc = CreateCompatibleDC(_hdc);
+	if (_hmdc == NULL) {
+		setlog("CreateCompatibleDC false");
+		return -2;
+	}
+
+	// updata_screen();
+	return 1;
 }
 
-long opGDI::UnBindEx() {
-  // setlog("bkgdi::UnBindEx()");
-  _hbmpscreen = (HBITMAP)SelectObject(_hmdc, _hbmp_old);
-  // delete[dwLen_2]hDib;
-  if (_hdc) DeleteDC(_hdc);
-  _hdc = NULL;
-  if (_hmdc) DeleteDC(_hmdc);
-  _hmdc = NULL;
-
-  if (_hbmpscreen) DeleteObject(_hbmpscreen);
-  _hbmpscreen = NULL;
-  // if (_hbmp_old)DeleteObject(_hbmp_old); _hbmp_old = NULL;
-  return 1;
+long opGDI::UnBindEx() 
+{
+	// setlog("bkgdi::UnBindEx()");
+	_hbmpscreen = (HBITMAP)SelectObject(_hmdc, _hbmp_old);
+	// delete[dwLen_2]hDib;
+	if (_hdc) DeleteDC(_hdc);
+	_hdc = NULL;
+	if (_hmdc) DeleteDC(_hmdc);
+	_hmdc = NULL;
+
+	if (_hbmpscreen) DeleteObject(_hbmpscreen);
+	_hbmpscreen = NULL;
+	// if (_hbmp_old)DeleteObject(_hbmp_old); _hbmp_old = NULL;
+	return 1;
 }
 
-bool opGDI::requestCapture(int x1, int y1, int w, int h, Image& img) {
-  // step 1.判断 窗口是否存在
-  if (!::IsWindow(_hwnd)) return 0;
-  img.create(w, h);
-  if (_render_type == RDT_NORMAL) {  // normal 拷贝的大小为实际需要的大小
-    //
-    /*	int w = rect.right - rect.left;
-            int h = rect.bottom - rect.top;*/
-    _hbmpscreen = CreateCompatibleBitmap(
-        _hdc, w, h);  //创建与指定的设备环境相关的设备兼容的位图
-    _hbmp_old = (HBITMAP)SelectObject(
-        _hmdc, _hbmpscreen);  //选择一对象到指定的设备上下文环境中
-
-    _bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
-    _bfh.bfSize = _bfh.bfOffBits + w * h * 4;
-    _bfh.bfType = static_cast<WORD>(0x4d42);
-
-    _bih.biBitCount = 32;  //每个像素字节大小
-    _bih.biCompression = BI_RGB;
-    _bih.biHeight = h;  //高度
-    _bih.biPlanes = 1;
-    _bih.biSize = sizeof(BITMAPINFOHEADER);
-    _bih.biSizeImage = w * h * 4;  //图像数据大小
-    _bih.biWidth = w;              //宽度
-
-    //对指定的源设备环境区域中的像素进行位块(bit_block)转换
-
-    RECT rc;
-    ::GetWindowRect(_hwnd, &rc);
-    // setlog("rect left =%d top =%d, dx =%d, dy = %d", rc.left, rc.top, dx_,
-    // dy_);
-    int src_x = x1 + rc.left + dx_;
-    int src_y = y1 + rc.top + dy_;
-    if (BitBlt(_hmdc, 0, 0, w, h, _hdc, src_x, src_y, SRCCOPY)) {
-      // ok
-    } else {
-      setlog("error in bitbit");
-    }
-
-    //函数获取指定兼容位图的位,然后将其作一个DIB—设备无关位图(Device-Independent
-    // Bitmap)使用的指定格式复制到一个缓冲区中 _pmutex->lock();
-    uchar* pshare = _shmem->data<byte>();
-    fmtFrameInfo(pshare, _hwnd, w, h);
-    GetDIBits(_hmdc, _hbmpscreen, 0L, (DWORD)h, pshare + sizeof(FrameInfo),
-              (LPBITMAPINFO)&_bih, (DWORD)DIB_RGB_COLORS);
-
-    //_pmutex->unlock();
-    if (_hbmpscreen) DeleteObject(_hbmpscreen);
-    _hbmpscreen = NULL;
-
-    //将数据拷贝到目标注意实际数据是反的
-
-    for (int i = 0; i < h; i++) {
-      memcpy(img.ptr<uchar>(i), _shmem->data<byte>() + (h - 1 - i) * 4 * w,
-             4 * w);
-    }
-  } else if (RDT_GDI_DX2 == _render_type) {
-    ATL::CImage image;
-    image.Create(w, h, _device_caps);
-    BitBlt(image.GetDC(), x1, y1, w, h, _hdc, 0, 0, SRCCOPY);
-    img.read(&image);
-    image.ReleaseDC();
-  } else {  // gdi ... 由于printwindow 函数的原因
-            // 截取大小为实际的窗口大小,在后续的处理中,需要转化成客户区大小
-    //
-    RECT rc;
-    ::GetWindowRect(_hwnd, &rc);
-    int ww = rc.right - rc.left;
-    int wh = rc.bottom - rc.top;
-    // setlog("_w w=%d %d _h h=%d %d,dx=%d dy=%d", _width, w, _height, h, dx_,
-    // dy_);
-    _hbmpscreen = CreateCompatibleBitmap(
-        _hdc, ww, wh);  //创建与指定的设备环境相关的设备兼容的位图
-    _hbmp_old = (HBITMAP)SelectObject(
-        _hmdc, _hbmpscreen);  //选择一对象到指定的设备上下文环境中
-
-    _bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
-    _bfh.bfSize = _bfh.bfOffBits + ww * wh * 4;
-    _bfh.bfType = static_cast<WORD>(0x4d42);
-
-    _bih.biBitCount = 32;  //每个像素字节大小
-    _bih.biCompression = BI_RGB;
-    _bih.biHeight = wh;  //高度
-    _bih.biPlanes = 1;
-    _bih.biSize = sizeof(BITMAPINFOHEADER);
-    _bih.biSizeImage = ww * wh * 4;  //图像数据大小
-    _bih.biWidth = ww;               //宽度
-
-    //对指定的源设备环境区域中的像素进行位块(bit_block)转换
-
-    if (_render_type == RDT_GDI) {
-      ::PrintWindow(_hwnd, _hmdc, 0);
-
-    } else {
-      ::UpdateWindow(_hwnd);
-      //::RedrawWindow(_hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE |
-      //:RDW_ALLCHILDREN | RDW_FRAME);
-      ::PrintWindow(_hwnd, _hmdc, 0);
-    }
-    //函数获取指定兼容位图的位,然后将其作一个DIB—设备无关位图(Device-Independent
-    // Bitmap)使用的指定格式复制到一个缓冲区中 _pmutex->lock();
-    uchar* pshare = _shmem->data<byte>();
-    fmtFrameInfo(pshare, _hwnd, w, h);
-    GetDIBits(_hmdc, _hbmpscreen, 0L, (DWORD)wh, pshare + sizeof(FrameInfo),
-              (LPBITMAPINFO)&_bih, (DWORD)DIB_RGB_COLORS);
-
-    if (_hbmpscreen) DeleteObject(_hbmpscreen);
-    _hbmpscreen = NULL;
-
-    //将数据拷贝到目标注意实际数据是反的(注意偏移)
-    auto ppixels = _shmem->data<byte>() + sizeof(FrameInfo);
-    for (int i = 0; i < h; i++) {
-      memcpy(img.ptr<uchar>(i),
-             ppixels + (wh - 1 - i - y1 - dy_) * 4 * ww + (x1 + dx_) * 4,
-             4 * w);
-    }
-  }
-  return 1;
+bool opGDI::requestCapture(int x1, int y1, int w, int h, Image& img) 
+{
+	// step 1.判断 窗口是否存在
+	if (!::IsWindow(_hwnd)) return 0;
+	img.create(w, h);
+	if (_render_type == RDT_NORMAL) {  // normal 拷贝的大小为实际需要的大小
+	  //
+	  /*	int w = rect.right - rect.left;
+			  int h = rect.bottom - rect.top;*/
+		_hbmpscreen = CreateCompatibleBitmap(
+			_hdc, w, h);  //创建与指定的设备环境相关的设备兼容的位图
+		_hbmp_old = (HBITMAP)SelectObject(
+			_hmdc, _hbmpscreen);  //选择一对象到指定的设备上下文环境中
+
+		_bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
+		_bfh.bfSize = _bfh.bfOffBits + w * h * 4;
+		_bfh.bfType = static_cast<WORD>(0x4d42);
+
+		_bih.biBitCount = 32;  //每个像素字节大小
+		_bih.biCompression = BI_RGB;
+		_bih.biHeight = h;  //高度
+		_bih.biPlanes = 1;
+		_bih.biSize = sizeof(BITMAPINFOHEADER);
+		_bih.biSizeImage = w * h * 4;  //图像数据大小
+		_bih.biWidth = w;              //宽度
+
+		//对指定的源设备环境区域中的像素进行位块(bit_block)转换
+
+		RECT rc;
+		::GetWindowRect(_hwnd, &rc);
+		// setlog("rect left =%d top =%d, dx =%d, dy = %d", rc.left, rc.top, dx_,
+		// dy_);
+		int src_x = x1 + rc.left + dx_;
+		int src_y = y1 + rc.top + dy_;
+		if (BitBlt(_hmdc, 0, 0, w, h, _hdc, src_x, src_y, SRCCOPY)) {
+			// ok
+		}
+		else {
+			setlog("error in bitbit");
+		}
+
+		//函数获取指定兼容位图的位,然后将其作一个DIB—设备无关位图(Device-Independent
+		// Bitmap)使用的指定格式复制到一个缓冲区中 _pmutex->lock();
+		uchar* pshare = _shmem->data<byte>();
+		fmtFrameInfo(pshare, _hwnd, w, h);
+		GetDIBits(_hmdc, _hbmpscreen, 0L, (DWORD)h, pshare + sizeof(FrameInfo),
+			(LPBITMAPINFO)&_bih, (DWORD)DIB_RGB_COLORS);
+
+		//_pmutex->unlock();
+		if (_hbmpscreen) DeleteObject(_hbmpscreen);
+		_hbmpscreen = NULL;
+
+		//将数据拷贝到目标注意实际数据是反的
+
+		for (int i = 0; i < h; i++) {
+			memcpy(img.ptr<uchar>(i), _shmem->data<byte>() + (h - 1 - i) * 4 * w,
+				4 * w);
+		}
+	}
+	else if (RDT_GDI_DX2 == _render_type) {
+		ATL::CImage image;
+		image.Create(w, h, _device_caps);
+		BitBlt(image.GetDC(), x1, y1, w, h, _hdc, 0, 0, SRCCOPY);
+		img.read(&image);
+		image.ReleaseDC();
+	}
+	else {  // gdi ... 由于printwindow 函数的原因
+		   // 截取大小为实际的窗口大小,在后续的处理中,需要转化成客户区大小
+   //
+		RECT rc;
+		::GetWindowRect(_hwnd, &rc);
+		int ww = rc.right - rc.left;
+		int wh = rc.bottom - rc.top;
+		// setlog("_w w=%d %d _h h=%d %d,dx=%d dy=%d", _width, w, _height, h, dx_,
+		// dy_);
+		_hbmpscreen = CreateCompatibleBitmap(
+			_hdc, ww, wh);  //创建与指定的设备环境相关的设备兼容的位图
+		_hbmp_old = (HBITMAP)SelectObject(
+			_hmdc, _hbmpscreen);  //选择一对象到指定的设备上下文环境中
+
+		_bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
+		_bfh.bfSize = _bfh.bfOffBits + ww * wh * 4;
+		_bfh.bfType = static_cast<WORD>(0x4d42);
+
+		_bih.biBitCount = 32;  //每个像素字节大小
+		_bih.biCompression = BI_RGB;
+		_bih.biHeight = wh;  //高度
+		_bih.biPlanes = 1;
+		_bih.biSize = sizeof(BITMAPINFOHEADER);
+		_bih.biSizeImage = ww * wh * 4;  //图像数据大小
+		_bih.biWidth = ww;               //宽度
+
+		//对指定的源设备环境区域中的像素进行位块(bit_block)转换
+
+		if (_render_type == RDT_GDI) {
+			::PrintWindow(_hwnd, _hmdc, 0);
+
+		}
+		else {
+			::UpdateWindow(_hwnd);
+			//::RedrawWindow(_hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE |
+			//:RDW_ALLCHILDREN | RDW_FRAME);
+			::PrintWindow(_hwnd, _hmdc, 0);
+		}
+		//函数获取指定兼容位图的位,然后将其作一个DIB—设备无关位图(Device-Independent
+		// Bitmap)使用的指定格式复制到一个缓冲区中 _pmutex->lock();
+		uchar* pshare = _shmem->data<byte>();
+		fmtFrameInfo(pshare, _hwnd, w, h);
+		GetDIBits(_hmdc, _hbmpscreen, 0L, (DWORD)wh, pshare + sizeof(FrameInfo),
+			(LPBITMAPINFO)&_bih, (DWORD)DIB_RGB_COLORS);
+
+		if (_hbmpscreen) DeleteObject(_hbmpscreen);
+		_hbmpscreen = NULL;
+
+		//将数据拷贝到目标注意实际数据是反的(注意偏移)
+		auto ppixels = _shmem->data<byte>() + sizeof(FrameInfo);
+		for (int i = 0; i < h; i++) {
+			memcpy(img.ptr<uchar>(i),
+				ppixels + (wh - 1 - i - y1 - dy_) * 4 * ww + (x1 + dx_) * 4,
+				4 * w);
+		}
+	}
+	return 1;
 }
-void opGDI::fmtFrameInfo(void* dst, HWND hwnd, int w, int h) {
-  m_frameInfo.hwnd = (unsigned __int64)hwnd;
-  m_frameInfo.frameId++;
-  m_frameInfo.time = ::GetTickCount();
-  m_frameInfo.width = w;
-  m_frameInfo.height = h;
-  m_frameInfo.fmtChk();
-  memcpy(dst, &m_frameInfo, sizeof(m_frameInfo));
+
+void opGDI::fmtFrameInfo(void* dst, HWND hwnd, int w, int h)
+{
+	m_frameInfo.hwnd = (unsigned __int64)hwnd;
+	m_frameInfo.frameId++;
+	m_frameInfo.time = ::GetTickCount();
+	m_frameInfo.width = w;
+	m_frameInfo.height = h;
+	m_frameInfo.fmtChk();
+	memcpy(dst, &m_frameInfo, sizeof(m_frameInfo));
 }

+ 6 - 7
gm/gm/background/display/opGDI.h

@@ -1,11 +1,14 @@
 #pragma once
 #ifndef __BKDISPLAY_H_
 #define __BKDISPLAY_H_
+
 #include <thread>
 #include "optype.h"
 #include "IDisplay.h"
+
 struct Image;
-class opGDI:public IDisplay
+
+class opGDI :public IDisplay
 {
 public:
 	opGDI();
@@ -15,14 +18,10 @@ public:
 	//long UnBind(HWND hwnd);
 	//解绑
 	long UnBindEx() override;
-	
-	
 	//long updata_screen();
-
 	//byte* get_data() override;
-
 	virtual bool requestCapture(int x1, int y1, int w, int h, Image& img)override;
-	
+
 private:
 	//设备句柄
 	HDC _hdc = NULL;
@@ -37,7 +36,7 @@ private:
 	int dx_, dy_;//去除标题栏
 	//bytearray temp_src;
 	FrameInfo m_frameInfo;
-	void fmtFrameInfo(void* dst,HWND hwnd, int w, int h);
+	void fmtFrameInfo(void* dst, HWND hwnd, int w, int h);
 };
 
 #endif

+ 1 - 1
gm/gm/background/keypad/Bkkeypad.cpp

@@ -27,7 +27,7 @@
 //	
 //}
 //
-bkkeypad::bkkeypad():_hwnd(0),_mode(0)
+bkkeypad::bkkeypad() :_hwnd(0), _mode(0)
 {
 }
 //

+ 1 - 4
gm/gm/background/keypad/Bkkeypad.h

@@ -1,5 +1,6 @@
 #pragma once
 #include "core/optype.h"
+
 class bkkeypad
 {
 public:
@@ -26,7 +27,3 @@ protected:
 	HWND _hwnd;
 	int _mode;
 };
-
-
-
-

+ 113 - 113
gm/gm/background/keypad/winkeypad.cpp

@@ -27,7 +27,7 @@ static uint oem_code(uint key) {
 
 }
 
-winkeypad::winkeypad():bkkeypad()
+winkeypad::winkeypad() :bkkeypad()
 {
 }
 
@@ -61,66 +61,66 @@ long winkeypad::KeyDown(long vk_code) {
 	vk_code = toupper(vk_code);
 
 	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL:
-	{
-	
-		INPUT Input = { 0 };
-		Input.type = INPUT_KEYBOARD;
-		Input.ki.wVk = (WORD)vk_code;
-		Input.ki.dwFlags = 0;
-
-		/*The function returns the number of events that it successfully inserted into the keyboard or mouse input stream.
-		If the function returns zero, the input was already blocked by another thread.
-		To get extended error information, call GetLastError.
-		This function fails when it is blocked by UIPI.
-		Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
-		*/
-		ret = ::SendInput(1, &Input, sizeof(INPUT));
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		/*Specification of WM_KEYDOWN :*/
-
-		/*wParam
-
-			Specifies the virtual - key code of the nonsystem key.
-		lParam
-			Specifies the repeat count, scan code, extended - key flag, context code,
-			previous key - state flag,
-			and transition - state flag, as shown in the following table.
-			0 - 15
-			Specifies the repeat count for the current message.The value is
-			the number of times the keystroke is
-			autorepeated as a result of the user holding down the key.If the
-			keystroke is held long enough, multiple messages are sent.However,
-			the repeat count is not cumulative.
-			16 - 23
-			Specifies the scan code.The value depends on the OEM.
-			24
-			Specifies whether the key is an extended key, such as the
-			right - hand ALT and CTRL keys that
-			appear on an enhanced 101 - or 102 - key keyboard.The value
-			is 1 if it is an extended key; otherwise, it is 0.
-			25 - 28
-			Reserved; do not use.
-			29
-			Specifies the context code.The value is always 0 for a WM_KEYDOWN message.
-			30
-			Specifies the previous key state.The value is 1 if the key
-			is down before the message is sent, or it is zero if the key is up.
-			31
-			Specifies the transition state.The value is always zero for a WM_KEYDOWN message.*/
-
-		DWORD lparam = 1u;
-		if (vk_code == VK_RCONTROL)
-			lparam |= 1u << 24;
-		lparam |= oem_code(vk_code) << 16;
-		ret = ::PostMessageW(_hwnd, WM_KEYDOWN, vk_code, lparam);
-		//ret = ::SendMessageW(_hwnd, WM_KEYDOWN, vk_code, 0);
-		if (ret == 0)setlog("error code=%d", GetLastError());
-		break;
-	}
+		case INPUT_TYPE::IN_NORMAL:
+			{
+
+				INPUT Input = { 0 };
+				Input.type = INPUT_KEYBOARD;
+				Input.ki.wVk = (WORD)vk_code;
+				Input.ki.dwFlags = 0;
+
+				/*The function returns the number of events that it successfully inserted into the keyboard or mouse input stream.
+				If the function returns zero, the input was already blocked by another thread.
+				To get extended error information, call GetLastError.
+				This function fails when it is blocked by UIPI.
+				Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
+				*/
+				ret = ::SendInput(1, &Input, sizeof(INPUT));
+				break;
+			}
+
+		case INPUT_TYPE::IN_WINDOWS: {
+				/*Specification of WM_KEYDOWN :*/
+
+				/*wParam
+
+					Specifies the virtual - key code of the nonsystem key.
+				lParam
+					Specifies the repeat count, scan code, extended - key flag, context code,
+					previous key - state flag,
+					and transition - state flag, as shown in the following table.
+					0 - 15
+					Specifies the repeat count for the current message.The value is
+					the number of times the keystroke is
+					autorepeated as a result of the user holding down the key.If the
+					keystroke is held long enough, multiple messages are sent.However,
+					the repeat count is not cumulative.
+					16 - 23
+					Specifies the scan code.The value depends on the OEM.
+					24
+					Specifies whether the key is an extended key, such as the
+					right - hand ALT and CTRL keys that
+					appear on an enhanced 101 - or 102 - key keyboard.The value
+					is 1 if it is an extended key; otherwise, it is 0.
+					25 - 28
+					Reserved; do not use.
+					29
+					Specifies the context code.The value is always 0 for a WM_KEYDOWN message.
+					30
+					Specifies the previous key state.The value is 1 if the key
+					is down before the message is sent, or it is zero if the key is up.
+					31
+					Specifies the transition state.The value is always zero for a WM_KEYDOWN message.*/
+
+				DWORD lparam = 1u;
+				if (vk_code == VK_RCONTROL)
+					lparam |= 1u << 24;
+				lparam |= oem_code(vk_code) << 16;
+				ret = ::PostMessageW(_hwnd, WM_KEYDOWN, vk_code, lparam);
+				//ret = ::SendMessageW(_hwnd, WM_KEYDOWN, vk_code, 0);
+				if (ret == 0)setlog("error code=%d", GetLastError());
+				break;
+			}
 	}
 
 
@@ -131,58 +131,58 @@ long winkeypad::KeyUp(long vk_code) {
 	long ret = 0;
 	vk_code = toupper(vk_code);
 	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL:
-	{
-		
-		INPUT Input = { 0 };
-		Input.type = INPUT_KEYBOARD;
-		Input.ki.wVk = vk_code;
-		Input.ki.dwFlags = KEYEVENTF_KEYUP;
-
-		/*The function returns the number of events that it successfully inserted into the keyboard or mouse input stream.
-		If the function returns zero, the input was already blocked by another thread.
-		To get extended error information, call GetLastError.
-		This function fails when it is blocked by UIPI.
-		Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
-		*/
-		ret = ::SendInput(1, &Input, sizeof(INPUT));
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		/*Specification of WM_KEYUP
-		wParam
-			Specifies the virtual - key code of the nonsystem key.
-			lParam
-			Specifies the repeat count, scan code, extended - key flag, context code,
-			previous key - state flag, and transition - state flag, as shown in the following table.
-			0 - 15
-			Specifies the repeat count for the current message.The value is the number of times the keystroke is
-			autorepeated as a result of the user holding down the key.
-			The repeat count is always one for a WM_KEYUP message.
-			16 - 23
-			Specifies the scan code.The value depends on the OEM.
-			24
-			Specifies whether the key is an extended key, such as the right - hand ALT and CTRL keys that
-			appear on an enhanced 101 - or 102 - key keyboard.The value is 1 if it is an extended key; otherwise, it is 0.
-			25 - 28
-			Reserved; do not use.
-			29
-			Specifies the context code.The value is always 0 for a WM_KEYUP message.
-			30
-			Specifies the previous key state.The value is always 1 for a WM_KEYUP message.
-			31
-			Specifies the transition state.The value is always 1 for a WM_KEYUP message.*/
-			//ret = ::SendMessageW(_hwnd, WM_KEYUP, vk_code, 0);
-		DWORD lparam = 1u;
-		if (vk_code == VK_RCONTROL)lparam |= 1u << 24;
-		lparam |= oem_code(vk_code) << 16;
-		lparam |= 1u << 30;
-		lparam |= 1u << 31;
-		ret = ::PostMessageW(_hwnd, WM_KEYUP, vk_code, lparam);
-		if (ret == 0)setlog("error2 code=%d", GetLastError());
-		break;
-	}
+		case INPUT_TYPE::IN_NORMAL:
+			{
+
+				INPUT Input = { 0 };
+				Input.type = INPUT_KEYBOARD;
+				Input.ki.wVk = vk_code;
+				Input.ki.dwFlags = KEYEVENTF_KEYUP;
+
+				/*The function returns the number of events that it successfully inserted into the keyboard or mouse input stream.
+				If the function returns zero, the input was already blocked by another thread.
+				To get extended error information, call GetLastError.
+				This function fails when it is blocked by UIPI.
+				Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
+				*/
+				ret = ::SendInput(1, &Input, sizeof(INPUT));
+				break;
+			}
+
+		case INPUT_TYPE::IN_WINDOWS: {
+				/*Specification of WM_KEYUP
+				wParam
+					Specifies the virtual - key code of the nonsystem key.
+					lParam
+					Specifies the repeat count, scan code, extended - key flag, context code,
+					previous key - state flag, and transition - state flag, as shown in the following table.
+					0 - 15
+					Specifies the repeat count for the current message.The value is the number of times the keystroke is
+					autorepeated as a result of the user holding down the key.
+					The repeat count is always one for a WM_KEYUP message.
+					16 - 23
+					Specifies the scan code.The value depends on the OEM.
+					24
+					Specifies whether the key is an extended key, such as the right - hand ALT and CTRL keys that
+					appear on an enhanced 101 - or 102 - key keyboard.The value is 1 if it is an extended key; otherwise, it is 0.
+					25 - 28
+					Reserved; do not use.
+					29
+					Specifies the context code.The value is always 0 for a WM_KEYUP message.
+					30
+					Specifies the previous key state.The value is always 1 for a WM_KEYUP message.
+					31
+					Specifies the transition state.The value is always 1 for a WM_KEYUP message.*/
+					//ret = ::SendMessageW(_hwnd, WM_KEYUP, vk_code, 0);
+				DWORD lparam = 1u;
+				if (vk_code == VK_RCONTROL)lparam |= 1u << 24;
+				lparam |= oem_code(vk_code) << 16;
+				lparam |= 1u << 30;
+				lparam |= 1u << 31;
+				ret = ::PostMessageW(_hwnd, WM_KEYUP, vk_code, lparam);
+				if (ret == 0)setlog("error2 code=%d", GetLastError());
+				break;
+			}
 	}
 
 

+ 1 - 1
gm/gm/background/keypad/winkeypad.h

@@ -2,7 +2,7 @@
 #ifndef _WIN_KEYPAD_H_
 #define _WIN_KEYPAD_H_
 #include "Bkkeypad.h"
-class winkeypad:public bkkeypad
+class winkeypad :public bkkeypad
 {
 public:
 	winkeypad();

+ 9 - 20
gm/gm/background/mouse/opMouseDx.cpp

@@ -6,8 +6,8 @@
 #include "BlackBone/Process/RPC/RemoteFunction.hpp"
 #include "../core/opEnv.h"
 #include "../HOOK/opMessage.h"
-opMouseDx::opMouseDx()
-	: _hwnd(NULL), _mode(0), _x(0), _y(0), _dpi(getDPI())
+
+opMouseDx::opMouseDx(): _hwnd(NULL), _mode(0), _x(0), _y(0), _dpi(getDPI())
 {
 }
 
@@ -62,7 +62,7 @@ long opMouseDx::Bind(HWND h, int mode)
 		}
 		if (injected)
 		{
-			using my_func_t = long(__stdcall *)(HWND, int);
+			using my_func_t = long(__stdcall*)(HWND, int);
 			auto PSetInputHook = blackbone::MakeRemoteFunction<my_func_t>(proc, dllname, "SetInputHook");
 			if (PSetInputHook)
 			{
@@ -113,7 +113,7 @@ long opMouseDx::UnBind()
 		{
 			dllname = is64 ? L"op_x64.dll" : L"op_x86.dll";
 		}
-		using my_func_t = long(__stdcall *)();
+		using my_func_t = long(__stdcall*)();
 		auto pReleaseInputHook = blackbone::MakeRemoteFunction<my_func_t>(proc, dllname, "ReleaseInputHook");
 		if (pReleaseInputHook)
 		{
@@ -140,7 +140,7 @@ long opMouseDx::UnBind()
 	return 1;
 }
 
-long opMouseDx::GetCursorPos(long &x, long &y)
+long opMouseDx::GetCursorPos(long& x, long& y)
 {
 	BOOL ret = FALSE;
 	POINT pt;
@@ -182,7 +182,6 @@ long opMouseDx::MoveToEx(int x, int y, int w, int h)
 long opMouseDx::LeftClick()
 {
 	long ret = 0, ret2 = 0;
-
 	///ret=::PostMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
 	ret = ::SendMessageTimeout(_hwnd, OP_WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr);
 	//ret = ::SendNotifyMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
@@ -205,18 +204,14 @@ long opMouseDx::LeftDoubleClick()
 long opMouseDx::LeftDown()
 {
 	long ret = 0;
-
 	ret = ::SendMessage(_hwnd, OP_WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
-
 	return ret;
 }
 
 long opMouseDx::LeftUp()
 {
 	long ret = 0;
-
 	ret = ::SendMessage(_hwnd, OP_WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(_x, _y));
-
 	return ret;
 }
 
@@ -232,18 +227,14 @@ long opMouseDx::MiddleClick()
 long opMouseDx::MiddleDown()
 {
 	long ret = 0;
-
 	ret = ::SendMessage(_hwnd, OP_WM_MBUTTONDOWN, MK_MBUTTON, MAKELPARAM(_x, _y));
-
 	return ret;
 }
 
 long opMouseDx::MiddleUp()
 {
 	long ret = 0;
-
 	ret = ::SendMessage(_hwnd, OP_WM_MBUTTONUP, MK_MBUTTON, MAKELPARAM(_x, _y));
-
 	return ret;
 }
 
@@ -251,11 +242,9 @@ long opMouseDx::RightClick()
 {
 	long ret = 0;
 	long r1, r2;
-
 	r1 = ::SendMessage(_hwnd, OP_WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(_x, _y));
 	r2 = ::SendMessage(_hwnd, OP_WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(_x, _y));
 	ret = r1 == 0 && r2 == 0 ? 1 : 0;
-
 	return ret;
 }
 
@@ -283,8 +272,8 @@ long opMouseDx::WheelDown()
 
 	/*
 		wParam
-		The high-order word indicates the distance the wheel is rotated, 
-		expressed in multiples or divisions of WHEEL_DELTA, which is 120. 
+		The high-order word indicates the distance the wheel is rotated,
+		expressed in multiples or divisions of WHEEL_DELTA, which is 120.
 		A positive value indicates that the wheel was rotated forward, away from the user;
 		a negative value indicates that the wheel was rotated backward, toward the user.
 		The low-order word indicates whether various virtual keys are down.
@@ -292,10 +281,10 @@ long opMouseDx::WheelDown()
 		lParam
 		The low-order word specifies the x-coordinate of the pointer,
 		relative to the upper-left corner of the screen.
-		The high-order word specifies the y-coordinate of the pointer, 
+		The high-order word specifies the y-coordinate of the pointer,
 		relative to the upper-left corner of the screen.
 		*/
-	//If an application processes this message, it should return zero.
+		//If an application processes this message, it should return zero.
 	ret = ::SendMessage(_hwnd, OP_WM_MOUSEWHEEL, MAKEWPARAM(-WHEEL_DELTA, 0), MAKELPARAM(_x, _y)) == 0 ? 1 : 0;
 
 	return ret;

+ 7 - 5
gm/gm/background/mouse/opMouseDx.h

@@ -1,23 +1,24 @@
 #pragma once
 #include "../core/optype.h"
 #include "opMouseWin.h"
-class opMouseDx: public opMouseWin
+
+class opMouseDx : public opMouseWin
 {
 public:
 	opMouseDx();
 	virtual ~opMouseDx();
 
-	virtual long Bind(HWND h,int mode);
+	virtual long Bind(HWND h, int mode);
 
 	virtual long UnBind();
 
-	virtual long GetCursorPos(long&x, long& y);
+	virtual long GetCursorPos(long& x, long& y);
 
 	virtual long MoveR(int rx, int ry);
 
 	virtual long MoveTo(int x, int y);
 
-	virtual long MoveToEx(int x, int y,int w,int h);
+	virtual long MoveToEx(int x, int y, int w, int h);
 
 	virtual long LeftClick();
 
@@ -42,10 +43,11 @@ public:
 	virtual long WheelDown();
 
 	virtual long WheelUp();
+
 private:
 	HWND _hwnd;
 	int _mode;
-	int _x,_y;
+	int _x, _y;
 	float _dpi;//screen dpi
 };
 

+ 285 - 249
gm/gm/background/mouse/opMouseWin.cpp

@@ -3,7 +3,8 @@
 #include "./core/globalVar.h"
 #include "./core/helpfunc.h"
 
-float opMouseWin::getDPI() {
+float opMouseWin::getDPI() 
+{
 	HDC hdcScreen;
 	hdcScreen = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
 
@@ -31,32 +32,33 @@ float opMouseWin::getDPI() {
 	return dpi;
 }
 
-opMouseWin::opMouseWin()
-	:_hwnd(NULL), _mode(0), _x(0), _y(0), _dpi(getDPI())
+opMouseWin::opMouseWin():_hwnd(NULL), _mode(0), _x(0), _y(0), _dpi(getDPI())
 {
 }
 
-
 opMouseWin::~opMouseWin()
 {
 	_hwnd = NULL;
 }
 
-long opMouseWin::Bind(HWND h,int mode) {
+long opMouseWin::Bind(HWND h, int mode) 
+{
 	_hwnd = h;
 	_mode = mode;
 	return 1;
 }
 
-long opMouseWin::UnBind() {
+long opMouseWin::UnBind() 
+{
 	_hwnd = 0; _mode = 0;
 	return 1;
 }
 
-long opMouseWin::GetCursorPos(long& x, long& y) {
+long opMouseWin::GetCursorPos(long& x, long& y) 
+{
 	BOOL ret = FALSE;
 	POINT pt;
-	ret=::GetCursorPos(&pt);
+	ret = ::GetCursorPos(&pt);
 	if (_hwnd != ::GetDesktopWindow()) {
 		ret = ::ScreenToClient(_hwnd, &pt);
 	}
@@ -64,53 +66,57 @@ long opMouseWin::GetCursorPos(long& x, long& y) {
 	return ret;
 }
 
-long opMouseWin::MoveR(int rx, int ry) {
+long opMouseWin::MoveR(int rx, int ry) 
+{
 	return MoveTo(_x + rx, _y + ry);
 }
 
-long opMouseWin::MoveTo(int x, int y) {
+long opMouseWin::MoveTo(int x, int y)
+{
 	x = x * _dpi;
 	y = y * _dpi;
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL:
+	switch (_mode) 
 	{
-		POINT pt;
-		pt.x = x, pt.y = y;
-		if (_hwnd)
-			::ClientToScreen(_hwnd, &pt);
-		x = pt.x, y = pt.y;
-		//setlog(L"hwnd:%d,pt:%d,%d",_hwnd, 0, y);
-		static double fScreenWidth = ::GetSystemMetrics(SM_CXSCREEN) - 1;
-		static double fScreenHeight = ::GetSystemMetrics(SM_CYSCREEN) - 1;
-		double fx = x * (65535.0f / fScreenWidth);
-		double fy = y * (65535.0f / fScreenHeight);
-		INPUT Input = { 0 };
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
-		Input.mi.dx = static_cast<LONG>(fx);
-		Input.mi.dy = static_cast<LONG>(fy);
-		/*The function returns the number of events that it successfully inserted into the keyboard or mouse input stream.
-		If the function returns zero, the input was already blocked by another thread.
-		To get extended error information, call GetLastError.
-		This function fails when it is blocked by UIPI.
-		Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
-		*/
-		ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		ret = ::SendMessage(_hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x, y)) == 0 ? 1 : 0;
-
-		break;
-	}
+		case INPUT_TYPE::IN_NORMAL:
+			{
+				POINT pt;
+				pt.x = x, pt.y = y;
+				if (_hwnd)
+					::ClientToScreen(_hwnd, &pt);
+				x = pt.x, y = pt.y;
+				//setlog(L"hwnd:%d,pt:%d,%d",_hwnd, 0, y);
+				static double fScreenWidth = ::GetSystemMetrics(SM_CXSCREEN) - 1;
+				static double fScreenHeight = ::GetSystemMetrics(SM_CYSCREEN) - 1;
+				double fx = x * (65535.0f / fScreenWidth);
+				double fy = y * (65535.0f / fScreenHeight);
+				INPUT Input = { 0 };
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
+				Input.mi.dx = static_cast<LONG>(fx);
+				Input.mi.dy = static_cast<LONG>(fy);
+				/*The function returns the number of events that it successfully inserted into the keyboard or mouse input stream.
+				If the function returns zero, the input was already blocked by another thread.
+				To get extended error information, call GetLastError.
+				This function fails when it is blocked by UIPI.
+				Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
+				*/
+				ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				ret = ::SendMessage(_hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x, y)) == 0 ? 1 : 0;
+
+				break;
+			}
 	}
 	_x = x, _y = y;
 	return ret;
 }
 
-long opMouseWin::MoveToEx(int x, int y, int w, int h) {
+long opMouseWin::MoveToEx(int x, int y, int w, int h) 
+{
 
 	if (w >= 2 && h >= 2)
 		return MoveTo(x + rand() % w, y + rand() % h);
@@ -118,273 +124,303 @@ long opMouseWin::MoveToEx(int x, int y, int w, int h) {
 		return MoveTo(x, y);
 }
 
-long opMouseWin::LeftClick() {
+long opMouseWin::LeftClick() 
+{
 	long ret = 0, ret2 = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left down 
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
-		ret = ::SendInput(1, &Input, sizeof(INPUT));
-
-		// left up
-		::ZeroMemory(&Input, sizeof(INPUT));
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
-		ret2 = ::SendInput(1, &Input, sizeof(INPUT));
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		///ret=::PostMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
-		ret = ::SendMessageTimeout(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr);
-		//ret = ::SendNotifyMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
-		//::Sleep(100);
-		//ret = ::SendMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
-		ret2=::SendMessageTimeout(_hwnd, WM_LBUTTONUP, 0, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr);
-		//ret2 = ::SendMessage(_hwnd, WM_LBUTTONUP, 0, MAKELPARAM(_x, _y));
-		//::SendMessage(_hwnd, WM_CAPTURECHANGED, 0, 0);
-		break;
-	}
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left down 
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
+				ret = ::SendInput(1, &Input, sizeof(INPUT));
+
+				// left up
+				::ZeroMemory(&Input, sizeof(INPUT));
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
+				ret2 = ::SendInput(1, &Input, sizeof(INPUT));
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				///ret=::PostMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
+				ret = ::SendMessageTimeout(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr);
+				//ret = ::SendNotifyMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
+				//::Sleep(100);
+				//ret = ::SendMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
+				ret2 = ::SendMessageTimeout(_hwnd, WM_LBUTTONUP, 0, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr);
+				//ret2 = ::SendMessage(_hwnd, WM_LBUTTONUP, 0, MAKELPARAM(_x, _y));
+				//::SendMessage(_hwnd, WM_CAPTURECHANGED, 0, 0);
+				break;
+			}
 	}
 	return ret && ret2 ? 1 : 0;
 }
 
-long opMouseWin::LeftDoubleClick() {
+long opMouseWin::LeftDoubleClick()
+{
 	long r1, r2;
-	r1=LeftClick();
+	r1 = LeftClick();
 	::Sleep(1);
-	r2=LeftClick();
+	r2 = LeftClick();
 	return r1 & r2 ? 1 : 0;
 }
 
-long opMouseWin::LeftDown() {
+long opMouseWin::LeftDown() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left down 
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
-		ret = ::SendInput(1, &Input, sizeof(INPUT));
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		ret = ::SendMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
-		break;
-	}
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left down 
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
+				ret = ::SendInput(1, &Input, sizeof(INPUT));
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				ret = ::SendMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y));
+				break;
+			}
 	}
 	return ret;
 }
 
-long opMouseWin::LeftUp() {
+long opMouseWin::LeftUp() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left up
-		::ZeroMemory(&Input, sizeof(INPUT));
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
-		ret = ::SendInput(1, &Input, sizeof(INPUT));
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		ret = ::SendMessage(_hwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(_x, _y));
-		break;
-	}
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left up
+				::ZeroMemory(&Input, sizeof(INPUT));
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
+				ret = ::SendInput(1, &Input, sizeof(INPUT));
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				ret = ::SendMessage(_hwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(_x, _y));
+				break;
+			}
 	}
 	return ret;
 }
 
-long opMouseWin::MiddleClick() {
+long opMouseWin::MiddleClick() 
+{
 	long r1, r2;
-	r1=MiddleDown();
+	r1 = MiddleDown();
 	::Sleep(1);
-	r2=MiddleUp();
+	r2 = MiddleUp();
 	return r1 & r2 ? 1 : 0;
 }
 
-long opMouseWin::MiddleDown() {
+long opMouseWin::MiddleDown() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left down 
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
-		ret = ::SendInput(1, &Input, sizeof(INPUT));
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		ret = ::SendMessage(_hwnd, WM_MBUTTONDOWN, MK_MBUTTON, MAKELPARAM(_x, _y));
-		break;
-	}
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left down 
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
+				ret = ::SendInput(1, &Input, sizeof(INPUT));
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				ret = ::SendMessage(_hwnd, WM_MBUTTONDOWN, MK_MBUTTON, MAKELPARAM(_x, _y));
+				break;
+			}
 
 	}
 	return ret;
 }
 
-long opMouseWin::MiddleUp() {
+long opMouseWin::MiddleUp() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left up
-		::ZeroMemory(&Input, sizeof(INPUT));
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
-		ret = ::SendInput(1, &Input, sizeof(INPUT));
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		ret = ::SendMessage(_hwnd, WM_MBUTTONUP, MK_MBUTTON, MAKELPARAM(_x, _y));
-		break;
-	}
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left up
+				::ZeroMemory(&Input, sizeof(INPUT));
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
+				ret = ::SendInput(1, &Input, sizeof(INPUT));
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				ret = ::SendMessage(_hwnd, WM_MBUTTONUP, MK_MBUTTON, MAKELPARAM(_x, _y));
+				break;
+			}
 	}
 	return ret;
 }
 
 
-long opMouseWin::RightClick() {
+long opMouseWin::RightClick() 
+{
 	long ret = 0;
 	long r1, r2;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left down 
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
-		r1 = ::SendInput(1, &Input, sizeof(INPUT));
-
-		// left up
-		::ZeroMemory(&Input, sizeof(INPUT));
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
-		r2 = ::SendInput(1, &Input, sizeof(INPUT)) ;
-		ret = r1 > 0 && r2 > 0 ? 1 : 0;
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		r1 = ::SendMessage(_hwnd, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(_x, _y));
-		r2 = ::SendMessage(_hwnd, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(_x, _y));
-		ret = r1 == 0 && r2 == 0 ? 1 : 0;
-		break;
-	}
-
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left down 
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
+				r1 = ::SendInput(1, &Input, sizeof(INPUT));
+
+				// left up
+				::ZeroMemory(&Input, sizeof(INPUT));
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
+				r2 = ::SendInput(1, &Input, sizeof(INPUT));
+				ret = r1 > 0 && r2 > 0 ? 1 : 0;
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS:
+			{
+				r1 = ::SendMessage(_hwnd, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(_x, _y));
+				r2 = ::SendMessage(_hwnd, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(_x, _y));
+				ret = r1 == 0 && r2 == 0 ? 1 : 0;
+				break;
+			}
 	}
 	return ret;
 }
 
-long opMouseWin::RightDown() {
+long opMouseWin::RightDown() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left down 
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
-		ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
-		break;
-	}
-	case	INPUT_TYPE::IN_WINDOWS: {
-		ret = ::PostMessage(_hwnd, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(_x, _y)) == 0 ? 1 : 0;
-		break;
-	}
-
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left down 
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
+				ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
+				break;
+			}
+		case	INPUT_TYPE::IN_WINDOWS: 
+			{
+				ret = ::PostMessage(_hwnd, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(_x, _y)) == 0 ? 1 : 0;
+				break;
+			}
 	}
 	return ret;
 }
 
-long opMouseWin::RightUp() {
+long opMouseWin::RightUp() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left up
-		::ZeroMemory(&Input, sizeof(INPUT));
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
-		ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		ret = ::PostMessage(_hwnd, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(_x, _y));
-		break;
-	}
+	switch (_mode) 
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				// left up
+				::ZeroMemory(&Input, sizeof(INPUT));
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
+				ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				ret = ::PostMessage(_hwnd, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(_x, _y));
+				break;
+			}
 	}
 	return ret;
 }
 
-long opMouseWin::WheelDown() {
+long opMouseWin::WheelDown() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		//down 
-		/*
-		If dwFlags contains MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement.
-		A positive value indicates that the wheel was rotated forward, away from the user;
-		a negative value indicates that the wheel was rotated backward, toward the user. 
-		One wheel click is defined as WHEEL_DELTA, which is 120.
-		*/
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_WHEEL;
-		Input.mi.mouseData = -WHEEL_DELTA;
-		ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
-		break;
-	}
-
-	case INPUT_TYPE::IN_WINDOWS: {
-		/*
-		wParam
-		The high-order word indicates the distance the wheel is rotated, 
-		expressed in multiples or divisions of WHEEL_DELTA, which is 120. 
-		A positive value indicates that the wheel was rotated forward, away from the user;
-		a negative value indicates that the wheel was rotated backward, toward the user.
-		The low-order word indicates whether various virtual keys are down.
-		This parameter can be one or more of the following values.
-		lParam
-		The low-order word specifies the x-coordinate of the pointer,
-		relative to the upper-left corner of the screen.
-		The high-order word specifies the y-coordinate of the pointer, 
-		relative to the upper-left corner of the screen.
-		*/
-		//If an application processes this message, it should return zero.
-		ret = ::SendMessage(_hwnd, WM_MOUSEWHEEL, MAKEWPARAM(-WHEEL_DELTA, 0), MAKELPARAM(_x, _y)) == 0 ? 1 : 0;
-		break;
+	switch (_mode)
+	{
+		case INPUT_TYPE::IN_NORMAL: 
+			{
+				INPUT Input = { 0 };
+				//down 
+				/*
+				If dwFlags contains MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement.
+				A positive value indicates that the wheel was rotated forward, away from the user;
+				a negative value indicates that the wheel was rotated backward, toward the user.
+				One wheel click is defined as WHEEL_DELTA, which is 120.
+				*/
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_WHEEL;
+				Input.mi.mouseData = -WHEEL_DELTA;
+				ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS: 
+			{
+				/*
+				wParam
+				The high-order word indicates the distance the wheel is rotated,
+				expressed in multiples or divisions of WHEEL_DELTA, which is 120.
+				A positive value indicates that the wheel was rotated forward, away from the user;
+				a negative value indicates that the wheel was rotated backward, toward the user.
+				The low-order word indicates whether various virtual keys are down.
+				This parameter can be one or more of the following values.
+				lParam
+				The low-order word specifies the x-coordinate of the pointer,
+				relative to the upper-left corner of the screen.
+				The high-order word specifies the y-coordinate of the pointer,
+				relative to the upper-left corner of the screen.
+				*/
+				//If an application processes this message, it should return zero.
+				ret = ::SendMessage(_hwnd, WM_MOUSEWHEEL, MAKEWPARAM(-WHEEL_DELTA, 0), MAKELPARAM(_x, _y)) == 0 ? 1 : 0;
+				break;
+			}
 	}
 
-	
-	}
-	
 	return ret;
 }
 
-long opMouseWin::WheelUp() {
+long opMouseWin::WheelUp() 
+{
 	long ret = 0;
-	switch (_mode) {
-	case INPUT_TYPE::IN_NORMAL: {
-		INPUT Input = { 0 };
-		// left up
-		Input.type = INPUT_MOUSE;
-		Input.mi.dwFlags = MOUSEEVENTF_WHEEL;
-		Input.mi.mouseData = WHEEL_DELTA;
-		ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
-		break;
+	switch (_mode)
+	{
+		case INPUT_TYPE::IN_NORMAL:
+			{
+				INPUT Input = { 0 };
+				// left up
+				Input.type = INPUT_MOUSE;
+				Input.mi.dwFlags = MOUSEEVENTF_WHEEL;
+				Input.mi.mouseData = WHEEL_DELTA;
+				ret = ::SendInput(1, &Input, sizeof(INPUT)) > 0 ? 1 : 0;
+				break;
+			}
+		case INPUT_TYPE::IN_WINDOWS:
+			{
+				ret = ::SendMessage(_hwnd, WM_MOUSEWHEEL, MAKEWPARAM(WHEEL_DELTA, 0), MAKELPARAM(_x, _y)) == 0 ? 1 : 0;
+				break;
+			}
 	}
 
-	case INPUT_TYPE::IN_WINDOWS: {
-		ret = ::SendMessage(_hwnd, WM_MOUSEWHEEL, MAKEWPARAM(WHEEL_DELTA, 0), MAKELPARAM(_x, _y)) == 0 ? 1 : 0;
-		break;
-	}
-	}
 	return ret;
 }

+ 4 - 4
gm/gm/background/mouse/opMouseWin.h

@@ -7,17 +7,17 @@ public:
 	opMouseWin();
 	virtual ~opMouseWin();
 
-	virtual long Bind(HWND h,int mode);
+	virtual long Bind(HWND h, int mode);
 
 	virtual long UnBind();
 
-	virtual long GetCursorPos(long&x, long& y);
+	virtual long GetCursorPos(long& x, long& y);
 
 	virtual long MoveR(int rx, int ry);
 
 	virtual long MoveTo(int x, int y);
 
-	virtual long MoveToEx(int x, int y,int w,int h);
+	virtual long MoveToEx(int x, int y, int w, int h);
 
 	virtual long LeftClick();
 
@@ -45,7 +45,7 @@ public:
 private:
 	HWND _hwnd;
 	int _mode;
-	int _x,_y;
+	int _x, _y;
 	float _dpi;//screen dpi
 };
 

+ 34 - 37
gm/gm/background/opBackground.cpp

@@ -3,12 +3,11 @@
 #include "./core/globalVar.h"
 #include "./core/helpfunc.h"
 #include "opBackground.h"
-
 #include "./display/opGDI.h"
 #include "./display/opDxGL.h""
-
 #include "./keypad/winkeypad.h""
 #include "./mouse/opMouseDx.h"
+
 opBackground::opBackground() : _hwnd(0), _is_bind(0), _pbkdisplay(nullptr), _bkmouse(new opMouseWin), _keypad(new winkeypad)
 {
 	_display_method = std::make_pair<wstring, wstring>(L"screen", L"");
@@ -30,7 +29,7 @@ opBackground::~opBackground()
 	SAFE_DELETE(_keypad);
 }
 
-long opBackground::BindWindow(long hwnd, const wstring &sdisplay, const wstring &smouse, const wstring &skeypad, long mode)
+long opBackground::BindWindow(long hwnd, const wstring& sdisplay, const wstring& smouse, const wstring& skeypad, long mode)
 {
 	//step 1.避免重复绑定
 	UnBindWindow();
@@ -228,7 +227,7 @@ void opBackground::unlock_data()
 
 long opBackground::get_height()
 {
-	auto &displayMethod = get_display_method();
+	auto& displayMethod = get_display_method();
 	if (displayMethod.first == L"pic")
 	{
 		return _pic.height;
@@ -237,12 +236,12 @@ long opBackground::get_height()
 	{
 		auto strPtr = displayMethod.second;
 #if OP64 == 1
-		auto ptr = (byte *)_wtoi64(strPtr.data());
+		auto ptr = (byte*)_wtoi64(strPtr.data());
 #else
-		auto ptr = (byte *)_wtoi(strPtr.data());
+		auto ptr = (byte*)_wtoi(strPtr.data());
 #endif //
 
-		auto bih = (BITMAPINFOHEADER *)(ptr + sizeof(BITMAPFILEHEADER));
+		auto bih = (BITMAPINFOHEADER*)(ptr + sizeof(BITMAPFILEHEADER));
 		return bih->biHeight < 0 ? -bih->biHeight : bih->biHeight;
 	}
 	else
@@ -253,7 +252,7 @@ long opBackground::get_height()
 
 long opBackground::get_width()
 {
-	auto &displayMethod = get_display_method();
+	auto& displayMethod = get_display_method();
 	if (displayMethod.first == L"pic")
 	{
 		return _pic.width;
@@ -262,12 +261,12 @@ long opBackground::get_width()
 	{
 		auto strPtr = displayMethod.second;
 #if OP64 == 1
-		auto ptr = (byte *)_wtoi64(strPtr.data());
+		auto ptr = (byte*)_wtoi64(strPtr.data());
 #else
-		auto ptr = (byte *)_wtoi(strPtr.data());
+		auto ptr = (byte*)_wtoi(strPtr.data());
 #endif //
 
-		auto bih = (BITMAPINFOHEADER *)(ptr + sizeof(BITMAPFILEHEADER));
+		auto bih = (BITMAPINFOHEADER*)(ptr + sizeof(BITMAPFILEHEADER));
 		return bih->biWidth;
 	}
 	else
@@ -276,9 +275,8 @@ long opBackground::get_width()
 	}
 }
 
-long opBackground::RectConvert(long &x1, long &y1, long &x2, long &y2)
+long opBackground::RectConvert(long& x1, long& y1, long& x2, long& y2)
 {
-
 	/*if (_pbkdisplay && (_display == RENDER_TYPE::NORMAL || _display == RENDER_TYPE::GDI)) {
 		x1 += _pbkdisplay->_client_x; y1 += _pbkdisplay->_client_y;
 		x2 += _pbkdisplay->_client_x; y2 += _pbkdisplay->_client_y;
@@ -311,7 +309,6 @@ long opBackground::RectConvert(long &x1, long &y1, long &x2, long &y2)
 
 long opBackground::get_image_type()
 {
-
 	if (_display_method.first == L"pic")
 		return 0;
 	else if (_display_method.first == L"mem")
@@ -323,16 +320,16 @@ long opBackground::get_image_type()
 	{
 		switch (GET_RENDER_TYPE(_display))
 		{
-		case RENDER_TYPE::NORMAL:
-			return -2;
-		case RENDER_TYPE::GDI:
-			return -1;
-		case RENDER_TYPE::DX:
-			return 0;
-		case RENDER_TYPE::OPENGL:
-			return -1;
-		default:
-			return 0;
+			case RENDER_TYPE::NORMAL:
+				return -2;
+			case RENDER_TYPE::GDI:
+				return -1;
+			case RENDER_TYPE::DX:
+				return 0;
+			case RENDER_TYPE::OPENGL:
+				return -1;
+			default:
+				return 0;
 		}
 	}
 }
@@ -360,12 +357,12 @@ bool opBackground::check_bind()
 	return BindWindow((long)::GetDesktopWindow(), L"normal", L"normal", L"normal", 0);
 }
 
-const std::pair<wstring, wstring> &opBackground::get_display_method() const
+const std::pair<wstring, wstring>& opBackground::get_display_method() const
 {
 	return _display_method;
 }
 
-long opBackground::set_display_method(const wstring &method)
+long opBackground::set_display_method(const wstring& method)
 {
 	if (method == L"screen")
 	{
@@ -388,17 +385,17 @@ long opBackground::set_display_method(const wstring &method)
 		{
 			auto strPtr = method.substr(idx + 4);
 #if OP64 == 1
-			auto ptr = (byte *)_wtoi64(strPtr.data());
+			auto ptr = (byte*)_wtoi64(strPtr.data());
 #else
-			auto ptr = (byte *)_wtoi(strPtr.data());
+			auto ptr = (byte*)_wtoi(strPtr.data());
 #endif //
 
 			if (ptr == nullptr)
 			{
 				return 0;
 			}
-			BITMAPFILEHEADER bfh = {0}; //bmp file header
-			BITMAPINFOHEADER bih = {0}; //bmp info header
+			BITMAPFILEHEADER bfh = { 0 }; //bmp file header
+			BITMAPINFOHEADER bih = { 0 }; //bmp info header
 			memcpy(&bfh, ptr, sizeof(bfh));
 			memcpy(&bih, ptr + sizeof(bfh), sizeof(bih));
 
@@ -421,8 +418,8 @@ long opBackground::set_display_method(const wstring &method)
 				for (int i = 0; i < h; i++)
 				{
 					memcpy(_pic.ptr<uchar>(i),
-						   ptr + sizeof(bfh) + sizeof(bih) + (h - 1 - i) * bih.biWidth * 4,
-						   bih.biWidth * 4);
+						ptr + sizeof(bfh) + sizeof(bih) + (h - 1 - i) * bih.biWidth * 4,
+						bih.biWidth * 4);
 				}
 			}
 			_display_method.first = L"mem";
@@ -434,7 +431,7 @@ long opBackground::set_display_method(const wstring &method)
 	}
 }
 
-bool opBackground::requestCapture(int x1, int y1, int w, int h, Image &img)
+bool opBackground::requestCapture(int x1, int y1, int w, int h, Image& img)
 {
 	wstring method = get_display_method().first;
 	if (method == L"screen")
@@ -449,9 +446,9 @@ bool opBackground::requestCapture(int x1, int y1, int w, int h, Image &img)
 	return false;
 }
 
-IDisplay *opBackground::createDisplay(int mode)
+IDisplay* opBackground::createDisplay(int mode)
 {
-	IDisplay *pans = 0;
+	IDisplay* pans = 0;
 
 	if (mode == RDT_NORMAL || GET_RENDER_TYPE(mode) == RENDER_TYPE::GDI)
 	{
@@ -468,7 +465,7 @@ IDisplay *opBackground::createDisplay(int mode)
 	return pans;
 }
 
-opMouseWin *opBackground::createMouse(int mode)
+opMouseWin* opBackground::createMouse(int mode)
 {
 	if (mode == INPUT_TYPE::IN_NORMAL || mode == INPUT_TYPE::IN_WINDOWS)
 		return new opMouseWin();
@@ -479,7 +476,7 @@ opMouseWin *opBackground::createMouse(int mode)
 	//return 0;
 }
 
-bkkeypad *opBackground::createKeypad(int mode)
+bkkeypad* opBackground::createKeypad(int mode)
 {
 	return new winkeypad();
 	//return 0;

+ 6 - 10
gm/gm/background/opBackground.h

@@ -3,61 +3,57 @@
 #define __BACKBASE_H_
 #include <string>
 #include "include/Image.hpp"
-
 #include "./display/IDisplay.h"
-
 #include "./mouse/opMouseWin.h"
 #include "./keypad/Bkkeypad.h"
 
-
 using std::wstring;
 
-
 class opBackground
 {
 public:
-	
 	opBackground();
 	~opBackground();
+
 public:
 	virtual long BindWindow(long hwnd, const wstring& sdisplay, const wstring& smouse, const wstring& skeypad, long mode);
 	virtual long UnBindWindow();
 	virtual long GetBindWindow();
 	virtual long IsBind();
 	//virtual long GetCursorPos(int& x, int& y);
-	
+
 	long GetDisplay();
 	/*byte* GetScreenData();*/
 	void lock_data();
 	void unlock_data();
 	long get_height();
 	long get_width();
-	long RectConvert(long&x1, long&y1, long&x2, long&y2);
+	long RectConvert(long& x1, long& y1, long& x2, long& y2);
 	//0:normal;-1 reserve 1 need cut
 	long get_image_type();
 	//����Ƿ�󶨻�������ǰ̨
 	bool check_bind();
 	const std::pair<wstring, wstring>& get_display_method()const;
 	long set_display_method(const wstring& method);
+	bool requestCapture(int x1, int y1, int w, int h, Image& img);
 
-	bool requestCapture(int x1,int y1,int w,int h,Image& img);
 private:
 	HWND _hwnd;
 	int _is_bind;
 	int _display;
 	int _mode;
-	std::pair<wstring,wstring> _display_method;
+	std::pair<wstring, wstring> _display_method;
 	Image _pic;
 
 	IDisplay* createDisplay(int mode);
 	opMouseWin* createMouse(int mode);
 	bkkeypad* createKeypad(int mode);
+
 public:
 	IDisplay* _pbkdisplay;
 	opMouseWin* _bkmouse;
 	bkkeypad* _keypad;
 	wstring _curr_path;
-	
 };
 #endif
 

+ 11 - 7
gm/gm/core/Cmder.h

@@ -1,23 +1,27 @@
 #pragma once
 #include "Pipe.h"
-class Cmder : public Pipe {
+
+class Cmder : public Pipe 
+{
 public:
-	void on_read(const string& ss)override {
+	void on_read(const string& ss)override 
+	{
 		_readed += ss;
-
 	}
-	string GetCmdStr(const string&cmd,size_t milseconds) {
+
+	string GetCmdStr(const string& cmd, size_t milseconds) 
+	{
 		open(cmd);
 		if (is_open()) {
-			auto deadline = clock()+milseconds;
-			while (is_open()&& clock()<deadline) {
+			auto deadline = clock() + milseconds;
+			while (is_open() && clock() < deadline) {
 				std::this_thread::sleep_for(std::chrono::milliseconds(1));
 			}
 			close();
 		}
 		return _readed;
 	}
+
 private:
 	string _readed;
-
 };

+ 13 - 13
gm/gm/core/Pipe.cpp

@@ -4,6 +4,7 @@
 #include<chrono>
 #include  "globalVar.h"
 #include "helpfunc.h"
+
 Pipe::Pipe()
 {
 	_hread = _hwrite = _hread2 = _hwrite2 = nullptr;
@@ -12,15 +13,13 @@ Pipe::Pipe()
 	_pthread = nullptr;
 }
 
-
-
-
 Pipe::~Pipe()
 {
 	close();
 }
 
-int Pipe::open(const string& cmd) {
+int Pipe::open(const string& cmd)
+{
 	_ai.nLength = sizeof(SECURITY_ATTRIBUTES);
 	_ai.bInheritHandle = true;
 	_ai.lpSecurityDescriptor = nullptr;
@@ -44,11 +43,11 @@ int Pipe::open(const string& cmd) {
 	return 1;
 }
 
-int Pipe::close() {
+int Pipe::close() 
+{
 	if (_reading) {
 		_reading = 0;
 		on_write("exit");
-
 		if (::WaitForSingleObject(_pi.hProcess, 1000) == WAIT_TIMEOUT) {
 			::TerminateProcess(_pi.hProcess, 0);
 			TerminateThread(_pthread->native_handle(), -1);
@@ -56,10 +55,7 @@ int Pipe::close() {
 		else {
 
 		}
-
 		_pthread->join();
-
-
 	}
 	SAFE_DELETE(_pthread);
 	SAFE_CLOSE(_hread);
@@ -71,11 +67,13 @@ int Pipe::close() {
 	return 0;
 }
 
-void Pipe::on_read(const string& info) {
+void Pipe::on_read(const string& info)
+{
 	std::cout << info << std::endl;
 }
 
-int Pipe::on_write(const string& info) {
+int Pipe::on_write(const string& info)
+{
 	if (_reading) {
 		unsigned long wlen = 0;
 
@@ -84,7 +82,8 @@ int Pipe::on_write(const string& info) {
 	return 0;
 }
 
-void Pipe::reader() {
+void Pipe::reader() 
+{
 	const static int buf_size = 1 << 10;
 	char buf[buf_size];
 	unsigned long read_len = 0;
@@ -101,7 +100,8 @@ void Pipe::reader() {
 	}
 }
 
-bool Pipe::is_open() {
+bool Pipe::is_open() 
+{
 	if (_reading) {
 		DWORD code = 0;
 		::GetExitCodeProcess(_pi.hProcess, &code);

+ 2 - 1
gm/gm/core/Pipe.h

@@ -2,11 +2,12 @@
 #include <windows.h>
 #include <string>
 #include <thread>
+
 class Pipe
 {
 public:
 	using handle_t = HANDLE;
-	using string=std::string;
+	using string = std::string;
 	Pipe();
 	virtual ~Pipe();
 	int open(const string& cmd);

+ 1 - 1
gm/gm/core/globalVar.h

@@ -7,7 +7,7 @@
 		CloseHandle(h); \
 	h = NULL;
 template <class Type>
-void SAFE_DELETE(Type *&ptr)
+void SAFE_DELETE(Type*& ptr)
 {
 	delete ptr;
 	ptr = nullptr;

+ 33 - 18
gm/gm/core/helpfunc.cpp

@@ -12,7 +12,8 @@
 #include <boost/stacktrace.hpp>
 #endif
 
-std::wstring _s2wstring(const std::string&s) {
+std::wstring _s2wstring(const std::string& s) 
+{
 	size_t nlen = s.length();
 
 	wchar_t* m_char;
@@ -25,7 +26,8 @@ std::wstring _s2wstring(const std::string&s) {
 	return ws;
 }
 
-std::string _ws2string(const std::wstring&ws) {
+std::string _ws2string(const std::wstring& ws)
+{
 	// std::string strLocale = setlocale(LC_ALL, "");
 	// const wchar_t* wchSrc = ws.c_str();
 	// size_t nDestSize = wcstombs(NULL, wchSrc, 0) + 1;
@@ -48,7 +50,8 @@ std::string _ws2string(const std::wstring&ws) {
 	return s;
 }
 
-long Path2GlobalPath(const std::wstring&file, const std::wstring& curr_path, std::wstring& out) {
+long Path2GlobalPath(const std::wstring& file, const std::wstring& curr_path, std::wstring& out) 
+{
 	if (::PathFileExistsW(file.c_str())) {
 		out = file;
 		return 1;
@@ -61,7 +64,8 @@ long Path2GlobalPath(const std::wstring&file, const std::wstring& curr_path, std
 	return 0;
 }
 
-long setlog(const wchar_t* format, ...) {
+long setlog(const wchar_t* format, ...) 
+{
 	va_list args;
 	wchar_t buf[512];
 	va_start(args, format);
@@ -69,11 +73,12 @@ long setlog(const wchar_t* format, ...) {
 	va_end(args);
 	wstring tmpw = buf;
 	string tmps = _ws2string(tmpw);
-	
+
 	return setlog(tmps.data());
 }
 
-long setlog(const char* format, ...) {
+long setlog(const char* format, ...) 
+{
 	std::stringstream ss(std::wstringstream::in | std::wstringstream::out);
 	va_list args;
 	char buf[512];
@@ -93,7 +98,6 @@ long setlog(const char* format, ...) {
 		<< boost::stacktrace::stacktrace() << std::endl;
 #endif // USE_BOOST_STACK_TRACE
 
-	
 	string s = ss.str();
 	if (opEnv::m_showErrorMsg == 1) {
 		MessageBoxA(NULL, s.data(), "error", MB_ICONERROR);
@@ -154,23 +158,28 @@ void split(const std::string& s, std::vector<std::string>& v, const std::string&
 		v.emplace_back(s.substr(pos1));
 }
 
-void wstring2upper(std::wstring& s) {
-	std::transform(s.begin(), s.end(),s.begin(), towupper);
+void wstring2upper(std::wstring& s) 
+{
+	std::transform(s.begin(), s.end(), s.begin(), towupper);
 }
 
-void string2upper(std::string& s) {
+void string2upper(std::string& s) 
+{
 	std::transform(s.begin(), s.end(), s.begin(), toupper);
 }
 
-void wstring2lower(std::wstring& s) {
+void wstring2lower(std::wstring& s) 
+{
 	std::transform(s.begin(), s.end(), s.begin(), towlower);
 }
 
-void string2lower(std::string& s) {
+void string2lower(std::string& s) 
+{
 	std::transform(s.begin(), s.end(), s.begin(), tolower);
 }
 
-void replacea(string& str, const string&oldval, const string& newval) {
+void replacea(string& str, const string& oldval, const string& newval) 
+{
 	size_t x0 = 0, dx = newval.length() - oldval.length() + 1;
 	size_t idx = str.find(oldval, x0);
 	while (idx != -1 && x0 >= 0) {
@@ -180,7 +189,8 @@ void replacea(string& str, const string&oldval, const string& newval) {
 	}
 }
 
-void replacew(wstring& str, const wstring&oldval, const wstring& newval) {
+void replacew(wstring& str, const wstring& oldval, const wstring& newval) 
+{
 	size_t x0 = 0, dx = newval.length() - oldval.length() + 1;
 	size_t idx = str.find(oldval, x0);
 	while (idx != -1 && x0 >= 0) {
@@ -190,17 +200,20 @@ void replacew(wstring& str, const wstring&oldval, const wstring& newval) {
 	}
 }
 
-std::ostream& operator<<(std::ostream& o, point_t const& rhs) {
+std::ostream& operator<<(std::ostream& o, point_t const& rhs) 
+{
 	o << rhs.x << "," << rhs.y;
 	return o;
 }
 
-std::wostream& operator<<(std::wostream& o, point_t const& rhs) {
+std::wostream& operator<<(std::wostream& o, point_t const& rhs) 
+{
 	o << rhs.x << L"," << rhs.y;
 	return o;
 }
 
-std::ostream& operator<<(std::ostream& o, FrameInfo const& rhs) {
+std::ostream& operator<<(std::ostream& o, FrameInfo const& rhs) 
+{
 	o << "hwnd:" << rhs.hwnd << std::endl
 		<< "frameId:" << rhs.frameId << std::endl
 		<< "time:" << rhs.time << std::endl
@@ -208,7 +221,9 @@ std::ostream& operator<<(std::ostream& o, FrameInfo const& rhs) {
 		<< "width:" << rhs.width << std::endl;
 	return o;
 }
-std::wostream& operator<<(std::wostream& o, FrameInfo const& rhs) {
+
+std::wostream& operator<<(std::wostream& o, FrameInfo const& rhs) 
+{
 	o << L"hwnd:" << rhs.hwnd << std::endl
 		<< L"frameId:" << rhs.frameId << std::endl
 		<< L"time:" << rhs.time << std::endl

+ 21 - 13
gm/gm/core/helpfunc.h

@@ -1,12 +1,14 @@
 #pragma once
 #ifndef __HELPFUCN_H_
 #define __HELPFUNC_H_
+
 #include "optype.h"
 #include "../background/display/frameInfo.h"
-std::wstring _s2wstring(const std::string&s);
-std::string _ws2string(const std::wstring&s);
+
+std::wstring _s2wstring(const std::string& s);
+std::string _ws2string(const std::wstring& s);
 //将路径转化为全局路径
-long Path2GlobalPath(const std::wstring&file, const std::wstring& curr_path, std::wstring& out);
+long Path2GlobalPath(const std::wstring& file, const std::wstring& curr_path, std::wstring& out);
 
 void split(const std::wstring& s, std::vector<std::wstring>& v, const std::wstring& c);
 void split(const std::string& s, std::vector<std::string>& v, const std::string& c);
@@ -17,8 +19,8 @@ void string2upper(std::string& s);
 void wstring2lower(std::wstring& s);
 void string2lower(std::string& s);
 
-void replacea(string& str, const string&oldval, const string& newval);
-void replacew(wstring& str, const wstring&oldval, const wstring& newval);
+void replacea(string& str, const string& oldval, const string& newval);
+void replacew(wstring& str, const wstring& oldval, const wstring& newval);
 
 
 //for debug
@@ -26,11 +28,13 @@ long setlog(const wchar_t* format, ...);
 //
 long setlog(const char* format, ...);
 
-int inline hex2bin(int c) {
+int inline hex2bin(int c) 
+{
 	return c <= L'9' ? c - L'0' : c - L'A' + 10;
 };
 
-int inline bin2hex(int c) {
+int inline bin2hex(int c) 
+{
 	int ans = 0;
 	int c1 = c >> 4 & 0xf;
 	int c2 = c & 0xf;
@@ -39,19 +43,22 @@ int inline bin2hex(int c) {
 	return ans;
 };
 
-constexpr int PTY(uint pt) {
+constexpr int PTY(uint pt) 
+{
 	return pt >> 16;
 }
 
-constexpr int PTX(uint pt) {
+constexpr int PTX(uint pt)
+{
 	return pt & 0xffff;
 }
 
 template<typename T>
-void nextVal(const T& t, int* next) {
+void nextVal(const T& t, int* next) 
+{
 	next[0] = -1;
 	int k = -1, j = 0;
-	while (j < (int)t.size()-1) {
+	while (j < (int)t.size() - 1) {
 		if (k == -1 || t[k] == t[j]) {
 			k++;
 			j++;
@@ -62,8 +69,10 @@ void nextVal(const T& t, int* next) {
 		}
 	}
 }
+
 template<typename T>
-int kmp(const T& s, const T& t) {
+int kmp(const T& s, const T& t) 
+{
 	vector<int> next(t.size());
 	nextVal(t, next.data());
 	int i = 0, j = 0;
@@ -81,7 +90,6 @@ int kmp(const T& s, const T& t) {
 
 std::ostream& operator<<(std::ostream& o, point_t const& rhs);
 std::wostream& operator<<(std::wostream& o, point_t const& rhs);
-
 std::ostream& operator<<(std::ostream& o, FrameInfo const& rhs);
 std::wostream& operator<<(std::wostream& o, FrameInfo const& rhs);
 

+ 21 - 17
gm/gm/core/opEnv.cpp

@@ -1,31 +1,35 @@
 #include "opEnv.h"
 #include <windows.h>
+
 void* opEnv::m_instance = nullptr;
 std::wstring opEnv::m_basePath;
 std::wstring opEnv::m_opName;
 int opEnv::m_showErrorMsg = 1;
-void opEnv::setInstance(void *instance)
+
+void opEnv::setInstance(void* instance)
 {
-    m_instance = instance;
-     wchar_t buff[512]={};
-    ::GetModuleFileNameW(static_cast<HINSTANCE>(m_instance),buff,512);
-    std::wstring s(buff);
-    size_t index =s.rfind(L"\\");
-    if(index!=s.npos){
-        m_basePath = s.substr(0,index);
-        m_opName = s.substr(index + 1);
-    }
+	m_instance = instance;
+	wchar_t buff[512] = {};
+	::GetModuleFileNameW(static_cast<HINSTANCE>(m_instance), buff, 512);
+	std::wstring s(buff);
+	size_t index = s.rfind(L"\\");
+	if (index != s.npos) {
+		m_basePath = s.substr(0, index);
+		m_opName = s.substr(index + 1);
+	}
 }
-void *opEnv::getInstance()
+
+void* opEnv::getInstance()
 {
-    return m_instance;
+	return m_instance;
 }
 
-std::wstring opEnv::getBasePath(){
-   
-    return m_basePath;
+std::wstring opEnv::getBasePath()
+{
+	return m_basePath;
 }
 
-std::wstring opEnv::getOpName(){
-    return m_opName;
+std::wstring opEnv::getOpName() 
+{
+	return m_opName;
 }

+ 9 - 9
gm/gm/core/opEnv.h

@@ -1,18 +1,18 @@
 #ifndef __OPENV_H_
 #define __OPENV_H_
 #include <string>
+
 class opEnv
 {
 public:
-    static void setInstance(void *instance);
-    static void *getInstance();
-    static std::wstring getBasePath();
-    static std::wstring getOpName();
-    static int m_showErrorMsg;
+	static void setInstance(void* instance);
+	static void* getInstance();
+	static std::wstring getBasePath();
+	static std::wstring getOpName();
+	static int m_showErrorMsg;
 private:
-    static void *m_instance;
-    static std::wstring m_basePath;
-    static std::wstring m_opName;
-    
+	static void* m_instance;
+	static std::wstring m_basePath;
+	static std::wstring m_opName;
 };
 #endif

+ 66 - 58
gm/gm/core/optype.h

@@ -1,12 +1,13 @@
 #pragma once
 #ifndef __optype_h_
 #define __optype_h_
+
 #include <Windows.h>
 #include <assert.h>
-
 #include <map>
 #include <string>
 #include <vector>
+
 using uint = unsigned int;
 using uchar = unsigned char;
 
@@ -17,77 +18,84 @@ using std::wstring;
 
 using bytearray = std::vector<uchar>;
 
-struct point_t {
-  int x, y;
-  point_t() : x(0), y(0) {}
-  point_t(int x_, int y_) : x(x_), y(y_) {}
-  bool operator<(const point_t& rhs) const {
-    if (std::abs(y - rhs.y) < 9)
-      return x < rhs.x;
-    else
-      return y < rhs.y;
-  }
-  bool operator==(const point_t& rhs) const { return x == rhs.x && y == rhs.y; }
+struct point_t 
+{
+	int x, y;
+	point_t() : x(0), y(0) {}
+	point_t(int x_, int y_) : x(x_), y(y_) {}
+	bool operator<(const point_t& rhs) const {
+		if (std::abs(y - rhs.y) < 9)
+			return x < rhs.x;
+		else
+			return y < rhs.y;
+	}
+	bool operator==(const point_t& rhs) const { return x == rhs.x && y == rhs.y; }
 };
 
 using vpoint_t = std::vector<point_t>;
 //(5,3) --> (2, 2, 1)
-class NumberGen {
-  int _q, _r;
+class NumberGen 
+{
+	int _q, _r;
 
- public:
-  NumberGen(int n, int cnt) : _q(n / cnt), _r(n % cnt) {}
-  int operator[](int idx) const { return idx < _r ? _q + 1 : _q; }
+public:
+	NumberGen(int n, int cnt) : _q(n / cnt), _r(n% cnt) {}
+	int operator[](int idx) const { return idx < _r ? _q + 1 : _q; }
 };
 
-struct rect_t {
-  rect_t() : x1(0), y1(0), x2(0), y2(0) {}
-  rect_t(int x1_, int y1_, int x2_, int y2_)
-      : x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
-  int x1, y1;
-  int x2, y2;
-  int width() const { return x2 - x1; }
-  int height() const { return y2 - y1; }
-  rect_t& shrinkRect(int w, int h) {
-    x2 -= w;
-    y2 -= h;
-    x2 += 1;
-    y2 += 1;
-    return *this;
-  }
-  bool valid() const { return 0 <= x1 && x1 < x2 && 0 <= y1 && y1 < y2; }
+struct rect_t 
+{
+	rect_t() : x1(0), y1(0), x2(0), y2(0) {}
+	rect_t(int x1_, int y1_, int x2_, int y2_)
+		: x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
+	int x1, y1;
+	int x2, y2;
+	int width() const { return x2 - x1; }
+	int height() const { return y2 - y1; }
 
-  void divideBlock(int count, bool vertical, std::vector<rect_t>& blocks) {
-    assert(valid());
+	rect_t& shrinkRect(int w, int h)
+	{
+		x2 -= w;
+		y2 -= h;
+		x2 += 1;
+		y2 += 1;
+		return *this;
+	}
+	bool valid() const { return 0 <= x1 && x1 < x2 && 0 <= y1 && y1 < y2; }
 
-    assert(count > 0);
-    blocks.resize(count);
-    if (vertical) {
-      NumberGen gen(height(), count);
-      int basey = y1;
-      for (int i = 0; i < count; ++i) {
-        blocks[i] = rect_t(x1, basey, x2, basey + gen[i]);
-        basey += gen[i];
-      }
+	void divideBlock(int count, bool vertical, std::vector<rect_t>& blocks) 
+	{
+		assert(valid());
+		assert(count > 0);
+		blocks.resize(count);
+		if (vertical) {
+			NumberGen gen(height(), count);
+			int basey = y1;
+			for (int i = 0; i < count; ++i) {
+				blocks[i] = rect_t(x1, basey, x2, basey + gen[i]);
+				basey += gen[i];
+			}
 
-    } else {
-      NumberGen gen(width(), count);
-      int basex = x1;
-      for (int i = 0; i < count; ++i) {
-        blocks[i] = rect_t(basex, y1, basex + gen[i], y2);
-        basex += gen[i];
-      }
-    }
-    assert(blocks.back().x2 == x2);
-    assert(blocks.back().y2 == y2);
-  }
+		}
+		else {
+			NumberGen gen(width(), count);
+			int basex = x1;
+			for (int i = 0; i < count; ++i) {
+				blocks[i] = rect_t(basex, y1, basex + gen[i], y2);
+				basex += gen[i];
+			}
+		}
+		assert(blocks.back().x2 == x2);
+		assert(blocks.back().y2 == y2);
+	}
 };
 
 using vrect_t = std::vector<rect_t>;
 
-struct point_desc_t {
-  int id;
-  point_t pos;
+struct point_desc_t 
+{
+	int id;
+	point_t pos;
 };
 
 using vpoint_desc_t = std::vector<point_desc_t>;

+ 0 - 4
gm/gm/gm.vcxproj

@@ -249,12 +249,8 @@
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
     </ClCompile>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="res\gm.rc2" />
-  </ItemGroup>
   <ItemGroup>
     <ClInclude Include="framework.h" />
-    <ClInclude Include="gm.h" />
     <ClInclude Include="Resource.h" />
     <ClInclude Include="targetver.h" />
   </ItemGroup>

+ 3 - 12
gm/gm/gm.vcxproj.filters

@@ -9,10 +9,6 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
     </Filter>
-    <Filter Include="资源文件">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
     <Filter Include="winapi">
       <UniqueIdentifier>{823a46bd-4d01-4fed-a473-7d90f7d4a27d}</UniqueIdentifier>
     </Filter>
@@ -43,6 +39,9 @@
     <Filter Include="keroi">
       <UniqueIdentifier>{823eedf1-d42a-492e-af1c-dd352261eb11}</UniqueIdentifier>
     </Filter>
+    <Filter Include="资源文件">
+      <UniqueIdentifier>{d5ae0fd4-6368-4468-ac08-0316da3586e6}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\3rd_party\src\kiero.cpp">
@@ -60,9 +59,6 @@
     <ClInclude Include="libop.h">
       <Filter>头文件</Filter>
     </ClInclude>
-    <ClInclude Include="gm.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
     <ClInclude Include="winapi\Injecter.h">
       <Filter>winapi</Filter>
     </ClInclude>
@@ -218,9 +214,4 @@
       <Filter>background\mouse</Filter>
     </ClCompile>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="res\gm.rc2">
-      <Filter>资源文件</Filter>
-    </None>
-  </ItemGroup>
 </Project>

File diff suppressed because it is too large
+ 1041 - 1022
gm/gm/imageProc/ImageLoc.cpp


+ 31 - 37
gm/gm/imageProc/ImageLoc.h

@@ -11,6 +11,7 @@
 #include "../include/Dict.h"
 #include "../include/color.h"
 #include "./compute/ThreadPool.h"
+
 inline int HEX2INT(wchar_t c) {
 	if (L'0' <= c && c <= L'9')
 		return c - L'0';
@@ -21,20 +22,20 @@ inline int HEX2INT(wchar_t c) {
 	return 0;
 }
 
-
 #define SET_BIT(x, idx) (x |= 1u << (idx))
-
 #define GET_BIT(x, idx) ((x >> (idx)) & 1u)
 
 using img_names = std::vector<std::wstring>;
 //检查是否为透明图
 int check_transparent(Image* img);
 //获取匹配点
-void get_match_points(const Image& img, vector<int>&points);
+void get_match_points(const Image& img, vector<int>& points);
 //generate next index for kmp
 void gen_next(const Image& img, vector<int>& next);
+
 //sum of all pixels
-int inline sum(uchar* begin, uchar* end) {
+int inline sum(uchar* begin, uchar* end) 
+{
 	int s = 0;
 	while (begin != end)
 		s += *begin++;
@@ -43,28 +44,28 @@ int inline sum(uchar* begin, uchar* end) {
 
 void extractConnectivity(const ImageBin& src, int threshold, std::vector<ImageBin>& out);
 
-
-struct gray_diff_t{
-	gray_diff_t(color_df_t const& cd):gray(cd.color.toGray()),diff(cd.df.toGray()){
+struct gray_diff_t 
+{
+	gray_diff_t(color_df_t const& cd) :gray(cd.color.toGray()), diff(cd.df.toGray()) {
 
 	}
 	unsigned char gray;
 	unsigned char diff;
 };
+
 /*
 此类用于实现一些图像功能,如图像定位,简单ocr等
 */
+
 class ImageBase
 {
 public:
-	
 	const static int _max_return_obj_ct = 1800;
 
 	using vcolor_diff_t = vector<color_df_t>;//rgb color-diff
-	using vgray_diff_t =vector<gray_diff_t>;//gray
+	using vgray_diff_t = vector<gray_diff_t>;//gray
 
 	ImageBase();
-
 	~ImageBase();
 
 	//brief:输入图像,建立图形矩阵,在图像操作前调用
@@ -76,26 +77,26 @@ public:
 	//long input_image(byte* psrc, int cols, int height,long x1,long y1,long x2,long y2, int type = 0);
 
 	void set_offset(int x1, int y1);
-	
+
 	long is_valid(long x, long y) {
-		return x >= 0 && y >= 0 && x < _src.width && y < _src.height;
+		return x >= 0 && y >= 0 && x < _src.width&& y < _src.height;
 	}
 
-	long GetPixel(long x, long y, color_t&cr);
+	long GetPixel(long x, long y, color_t& cr);
 
-	long CmpColor(color_t color, std::vector<color_df_t>&colors, double sim);
+	long CmpColor(color_t color, std::vector<color_df_t>& colors, double sim);
 
-	long FindColor(std::vector<color_df_t>&colors,int dir, long&x, long&y);
+	long FindColor(std::vector<color_df_t>& colors, int dir, long& x, long& y);
 
-	long FindColorEx(std::vector<color_df_t>&colors, std::wstring& retstr);
+	long FindColorEx(std::vector<color_df_t>& colors, std::wstring& retstr);
 
-	long FindMultiColor(std::vector<color_df_t>&first_color, std::vector<pt_cr_df_t>& offset_color, double sim, long dir, long&x, long&y);
+	long FindMultiColor(std::vector<color_df_t>& first_color, std::vector<pt_cr_df_t>& offset_color, double sim, long dir, long& x, long& y);
 
-	long FindMultiColorEx(std::vector<color_df_t>&first_color, std::vector<pt_cr_df_t>& offset_color, double sim, long dir, std::wstring& retstr);
+	long FindMultiColorEx(std::vector<color_df_t>& first_color, std::vector<pt_cr_df_t>& offset_color, double sim, long dir, std::wstring& retstr);
 
-	long FindPic(std::vector<Image*>&pics,color_t dfcolor,double sim, long&x, long&y);
+	long FindPic(std::vector<Image*>& pics, color_t dfcolor, double sim, long& x, long& y);
 
-	long FindPicTh(std::vector<Image*>&pics,color_t dfcolor,double sim, long&x, long&y);
+	long FindPicTh(std::vector<Image*>& pics, color_t dfcolor, double sim, long& x, long& y);
 
 	long FindPicEx(std::vector<Image*>& pics, color_t dfcolor, double sim, vpoint_desc_t& vpd);
 
@@ -109,47 +110,41 @@ public:
 
 	long OcrEx(Dict& dict, double sim, std::wstring& out_str);
 
-	long FindStr(Dict& dict, const vector<wstring>& vstr,  double sim, long& retx, long& rety);
+	long FindStr(Dict& dict, const vector<wstring>& vstr, double sim, long& retx, long& rety);
 
 	long FindStrEx(Dict& dict, const vector<wstring>& vstr, double sim, std::wstring& out_str);
 	//描述:查找目标图像中的直线
 	//输入:精度
 	//输出:outStr:直线描述[法线角度,直线到原点的距离];ret:该直线上的点的数量
 	long FindLine(double sim, std::wstring& outStr);
+
 private:
 	//rgb像素匹配
 	template<bool nodfcolor>
-	long simple_match(long x, long y, Image* timg, color_t dfcolor,int tnrom, double sim);
+	long simple_match(long x, long y, Image* timg, color_t dfcolor, int tnrom, double sim);
 	//透明图匹配
 	template<bool nodfcolor>
 	long trans_match(long x, long y, Image* timg, color_t dfcolor, vector<uint>points, int max_error);
 	//灰度匹配
 	long real_match(long x, long y, ImageBin* timg, int tnorm, double sim);
 	//记录和
-	void record_sum(const ImageBin & gray);
+	void record_sum(const ImageBin& gray);
 	//[x1,x2),[y1,y2)
 	int region_sum(int x1, int y1, int x2, int y2);
-
-	
-
 	int get_bk_color(inputbin bin);
-
-	
-	
 	//垂直方向投影,投到x轴
 	void binshadowx(const rect_t& rc, std::vector<rect_t>& out_put);
 	//水平方向投影,投到(y)轴
-	void binshadowy(const rect_t& rc, std::vector<rect_t>&out_put);
+	void binshadowy(const rect_t& rc, std::vector<rect_t>& out_put);
 
-
-	
 	//ocr 完全匹配模式
-	void _bin_ocr(const Dict& dict, std::map<point_t, std::wstring>&ps);
+	void _bin_ocr(const Dict& dict, std::map<point_t, std::wstring>& ps);
 	//ocr 模糊匹配模式
-	void _bin_ocr(const Dict& dict,double sim, std::map<point_t, std::wstring>&ps);
+	void _bin_ocr(const Dict& dict, double sim, std::map<point_t, std::wstring>& ps);
 	//ocr wrapper
 	//template<int _type>
 	//void bin_ocr(const Image& binary, Image& record, const Dict& dict, int* max_error, std::wstring& outstr);
+
 public:
 	/*
 	if(abs(cr-src)<=df) pixel=1;
@@ -162,9 +157,7 @@ public:
 	void bin_image_cut(int min_word_h, const rect_t& inrc, rect_t& outrc);
 	void get_rois(int min_word_h, std::vector<rect_t>& vroi);
 	//ocr识别,返回识别到的字及对应坐标
-
-	void bin_ocr(const Dict& dict, double sim, std::map<point_t, std::wstring>&ps);
-
+	void bin_ocr(const Dict& dict, double sim, std::map<point_t, std::wstring>& ps);
 
 public:
 	Image _src;
@@ -172,6 +165,7 @@ public:
 	ImageBin _record;
 	ImageBin _binary;
 	Image _sum;
+
 private:
 	//起始点
 	int _x1, _y1;

+ 43 - 41
gm/gm/imageProc/ImageProc.cpp

@@ -5,6 +5,7 @@
 #include <bitset>
 #include <algorithm>
 #include <sstream>
+
 ImageProc::ImageProc()
 {
 	_curr_idx = 0;
@@ -15,7 +16,7 @@ ImageProc::~ImageProc()
 {
 }
 
-long ImageProc::Capture(const std::wstring &file)
+long ImageProc::Capture(const std::wstring& file)
 {
 	wstring fpath = file;
 	if (fpath.find(L'\\') == -1)
@@ -24,14 +25,14 @@ long ImageProc::Capture(const std::wstring &file)
 	return _src.write(fpath.data());
 }
 
-long ImageProc::CmpColor(long x, long y, const std::wstring &scolor, double sim)
+long ImageProc::CmpColor(long x, long y, const std::wstring& scolor, double sim)
 {
 	std::vector<color_df_t> vcolor;
 	str2colordfs(scolor, vcolor);
 	return ImageBase::CmpColor(_src.at<color_t>(0, 0), vcolor, sim);
 }
 
-long ImageProc::FindColor(const wstring &color, double sim, long dir, long &x, long &y)
+long ImageProc::FindColor(const wstring& color, double sim, long dir, long& x, long& y)
 {
 	std::vector<color_df_t> colors;
 	str2colordfs(color, colors);
@@ -40,14 +41,14 @@ long ImageProc::FindColor(const wstring &color, double sim, long dir, long &x, l
 	return ImageBase::FindColor(colors, dir, x, y);
 }
 
-long ImageProc::FindColoEx(const wstring &color, double sim, long dir, wstring &retstr)
+long ImageProc::FindColoEx(const wstring& color, double sim, long dir, wstring& retstr)
 {
 	std::vector<color_df_t> colors;
 	str2colordfs(color, colors);
 	return ImageBase::FindColorEx(colors, retstr);
 }
 
-long ImageProc::FindMultiColor(const wstring &first_color, const wstring &offset_color, double sim, long dir, long &x, long &y)
+long ImageProc::FindMultiColor(const wstring& first_color, const wstring& offset_color, double sim, long dir, long& x, long& y)
 {
 	std::vector<color_df_t> vfirst_color;
 	str2colordfs(first_color, vfirst_color);
@@ -55,7 +56,7 @@ long ImageProc::FindMultiColor(const wstring &first_color, const wstring &offset
 	split(offset_color, vseconds, L",");
 	std::vector<pt_cr_df_t> voffset_cr;
 	pt_cr_df_t tp;
-	for (auto &it : vseconds)
+	for (auto& it : vseconds)
 	{
 		size_t id1, id2;
 		id1 = it.find(L'|');
@@ -73,7 +74,7 @@ long ImageProc::FindMultiColor(const wstring &first_color, const wstring &offset
 	return ImageBase::FindMultiColor(vfirst_color, voffset_cr, sim, dir, x, y);
 }
 
-long ImageProc::FindMultiColorEx(const wstring &first_color, const wstring &offset_color, double sim, long dir, wstring &retstr)
+long ImageProc::FindMultiColorEx(const wstring& first_color, const wstring& offset_color, double sim, long dir, wstring& retstr)
 {
 	std::vector<color_df_t> vfirst_color;
 	str2colordfs(first_color, vfirst_color);
@@ -81,7 +82,7 @@ long ImageProc::FindMultiColorEx(const wstring &first_color, const wstring &offs
 	split(offset_color, vseconds, L",");
 	std::vector<pt_cr_df_t> voffset_cr;
 	pt_cr_df_t tp;
-	for (auto &it : vseconds)
+	for (auto& it : vseconds)
 	{
 		size_t id1, id2;
 		id1 = it.find(L'|');
@@ -98,10 +99,11 @@ long ImageProc::FindMultiColorEx(const wstring &first_color, const wstring &offs
 	}
 	return ImageBase::FindMultiColorEx(vfirst_color, voffset_cr, sim, dir, retstr);
 }
+
 //图形定位
-long ImageProc::FindPic(const std::wstring &files, const wstring &delta_colors, double sim, long dir, long &x, long &y)
+long ImageProc::FindPic(const std::wstring& files, const wstring& delta_colors, double sim, long dir, long& x, long& y)
 {
-	vector<Image *> vpic;
+	vector<Image*> vpic;
 	//vector<color_t> vcolor;
 	color_t dfcolor;
 	vector<std::wstring> vpic_name;
@@ -116,10 +118,11 @@ long ImageProc::FindPic(const std::wstring &files, const wstring &delta_colors,
 		_pic_cache.clear();
 	return ret;
 }
+
 //
-long ImageProc::FindPicEx(const std::wstring &files, const wstring &delta_colors, double sim, long dir, wstring &retstr, bool returnID)
+long ImageProc::FindPicEx(const std::wstring& files, const wstring& delta_colors, double sim, long dir, wstring& retstr, bool returnID)
 {
-	vector<Image *> vpic;
+	vector<Image*> vpic;
 	vpoint_desc_t vpd;
 	//vector<color_t> vcolor;
 	color_t dfcolor;
@@ -128,17 +131,17 @@ long ImageProc::FindPicEx(const std::wstring &files, const wstring &delta_colors
 	dfcolor.str2color(delta_colors);
 	sim = 0.5 + sim / 2;
 	long ret = ImageBase::FindPicExTh(vpic, dfcolor, sim, vpd);
-	std::wstringstream ss(std::wstringstream::in|std::wstringstream::out);
+	std::wstringstream ss(std::wstringstream::in | std::wstringstream::out);
 	if (returnID)
 	{
-		for (auto &it : vpd)
+		for (auto& it : vpd)
 		{
 			ss << it.id << L"," << it.pos << L"|";
 		}
 	}
 	else
 	{
-		for (auto &it : vpd)
+		for (auto& it : vpd)
 		{
 			ss << vpic_name[it.id] << L"," << it.pos << L"|";
 		}
@@ -152,9 +155,8 @@ long ImageProc::FindPicEx(const std::wstring &files, const wstring &delta_colors
 	return ret;
 }
 
-long ImageProc::FindColorBlock(const wstring &color, double sim, long count, long height, long width, long &x, long &y)
+long ImageProc::FindColorBlock(const wstring& color, double sim, long count, long height, long width, long& x, long& y)
 {
-
 	vector<color_df_t> colors;
 	if (str2colordfs(color, colors) == 0)
 	{
@@ -167,7 +169,7 @@ long ImageProc::FindColorBlock(const wstring &color, double sim, long count, lon
 	return ImageBase::FindColorBlock(sim, count, height, width, x, y);
 }
 
-long ImageProc::FindColorBlockEx(const wstring &color, double sim, long count, long height, long width, wstring &retstr)
+long ImageProc::FindColorBlockEx(const wstring& color, double sim, long count, long height, long width, wstring& retstr)
 {
 	vector<color_df_t> colors;
 	if (str2colordfs(color, colors) == 0)
@@ -181,7 +183,7 @@ long ImageProc::FindColorBlockEx(const wstring &color, double sim, long count, l
 	return ImageBase::FindColorBlockEx(sim, count, height, width, retstr);
 }
 
-long ImageProc::SetDict(int idx, const wstring &file_name)
+long ImageProc::SetDict(int idx, const wstring& file_name)
 {
 	if (idx < 0 || idx >= _max_dict)
 		return 0;
@@ -202,12 +204,12 @@ long ImageProc::SetDict(int idx, const wstring &file_name)
 	return _dicts[idx].empty() ? 0 : 1;
 }
 
-long ImageProc::SetMemDict(int idx, void *data, long size)
+long ImageProc::SetMemDict(int idx, void* data, long size)
 {
 	if (idx < 0 || idx >= _max_dict)
 		return 0;
 	_dicts[idx].clear();
-	_dicts[idx].read_memory_dict_dm((const char *)data, size);
+	_dicts[idx].read_memory_dict_dm((const char*)data, size);
 	return _dicts[idx].empty() ? 0 : 1;
 }
 
@@ -219,7 +221,7 @@ long ImageProc::UseDict(int idx)
 	return 1;
 }
 
-long ImageProc::OCR(const wstring &color, double sim, std::wstring &out_str)
+long ImageProc::OCR(const wstring& color, double sim, std::wstring& out_str)
 {
 	out_str.clear();
 	vector<color_df_t> colors;
@@ -251,7 +253,7 @@ wstring ImageProc::GetColor(long x, long y)
 	}
 }
 
-int ImageProc::str2colordfs(const wstring &color_str, std::vector<color_df_t> &colors)
+int ImageProc::str2colordfs(const wstring& color_str, std::vector<color_df_t>& colors)
 {
 	std::vector<wstring> vstr, vstr2;
 	color_df_t cr;
@@ -266,7 +268,7 @@ int ImageProc::str2colordfs(const wstring &color_str, std::vector<color_df_t> &c
 		ret = 1;
 	}
 	split(ret ? color_str.substr(1) : color_str, vstr, L"|");
-	for (auto &it : vstr)
+	for (auto& it : vstr)
 	{
 		split(it, vstr2, L"-");
 		cr.color.str2color(vstr2[0]);
@@ -276,27 +278,27 @@ int ImageProc::str2colordfs(const wstring &color_str, std::vector<color_df_t> &c
 	return ret;
 }
 
-void ImageProc::str2colors(const wstring &color, std::vector<color_t> &vcolor)
+void ImageProc::str2colors(const wstring& color, std::vector<color_t>& vcolor)
 {
 	std::vector<wstring> vstr, vstr2;
 	color_t cr;
 	vcolor.clear();
 	split(color, vstr, L"|");
-	for (auto &it : vstr)
+	for (auto& it : vstr)
 	{
 		cr.str2color(it);
 		vcolor.push_back(cr);
 	}
 }
 
-long ImageProc::LoadPic(const wstring &files)
+long ImageProc::LoadPic(const wstring& files)
 {
 	//std::vector<wstring>vstr, vstr2;
 	std::vector<wstring> vstr;
 	int loaded = 0;
 	split(files, vstr, L"|");
 	wstring tp;
-	for (auto &it : vstr)
+	for (auto& it : vstr)
 	{
 		//路径转化
 		if (!Path2GlobalPath(it, _curr_path, tp))
@@ -312,13 +314,13 @@ long ImageProc::LoadPic(const wstring &files)
 	return loaded;
 }
 
-long ImageProc::FreePic(const wstring &files)
+long ImageProc::FreePic(const wstring& files)
 {
 	std::vector<wstring> vstr;
 	int loaded = 0;
 	split(files, vstr, L"|");
 	wstring tp;
-	for (auto &it : vstr)
+	for (auto& it : vstr)
 	{
 		//看当前目录
 		auto cache_it = _pic_cache.find(it);
@@ -338,7 +340,7 @@ long ImageProc::FreePic(const wstring &files)
 	return loaded;
 }
 
-long ImageProc::LoadMemPic(const wstring &file_name, void *data, long size)
+long ImageProc::LoadMemPic(const wstring& file_name, void* data, long size)
 {
 	try
 	{
@@ -354,14 +356,14 @@ long ImageProc::LoadMemPic(const wstring &file_name, void *data, long size)
 	return 1;
 }
 
-void ImageProc::files2mats(const wstring &files, std::vector<Image *> &vpic, std::vector<wstring> &vstr)
+void ImageProc::files2mats(const wstring& files, std::vector<Image*>& vpic, std::vector<wstring>& vstr)
 {
 	//std::vector<wstring>vstr, vstr2;
-	Image *pm;
+	Image* pm;
 	vpic.clear();
 	split(files, vstr, L"|");
 	wstring tp;
-	for (auto &it : vstr)
+	for (auto& it : vstr)
 	{
 		//先在缓存中查找是否已加载,包括从内存中加载的文件
 		if (_pic_cache.count(it))
@@ -388,7 +390,7 @@ void ImageProc::files2mats(const wstring &files, std::vector<Image *> &vpic, std
 	}
 }
 
-long ImageProc::OcrEx(const wstring &color, double sim, std::wstring &out_str)
+long ImageProc::OcrEx(const wstring& color, double sim, std::wstring& out_str)
 {
 	out_str.clear();
 	vector<color_df_t> colors;
@@ -406,7 +408,7 @@ long ImageProc::OcrEx(const wstring &color, double sim, std::wstring &out_str)
 	return ImageBase::OcrEx(_dicts[_curr_idx], sim, out_str);
 }
 
-long ImageProc::FindStr(const wstring &str, const wstring &color, double sim, long &retx, long &rety)
+long ImageProc::FindStr(const wstring& str, const wstring& color, double sim, long& retx, long& rety)
 {
 	vector<wstring> vstr;
 	vector<color_df_t> colors;
@@ -424,7 +426,7 @@ long ImageProc::FindStr(const wstring &str, const wstring &color, double sim, lo
 	return ImageBase::FindStr(_dicts[_curr_idx], vstr, sim, retx, rety);
 }
 
-long ImageProc::FindStrEx(const wstring &str, const wstring &color, double sim, std::wstring &out_str)
+long ImageProc::FindStrEx(const wstring& str, const wstring& color, double sim, std::wstring& out_str)
 {
 	out_str.clear();
 	vector<wstring> vstr;
@@ -443,7 +445,7 @@ long ImageProc::FindStrEx(const wstring &str, const wstring &color, double sim,
 	return ImageBase::FindStrEx(_dicts[_curr_idx], vstr, sim, out_str);
 }
 
-long ImageProc::OcrAuto(double sim, std::wstring &retstr)
+long ImageProc::OcrAuto(double sim, std::wstring& retstr)
 {
 	retstr.clear();
 
@@ -457,7 +459,7 @@ long ImageProc::OcrAuto(double sim, std::wstring &retstr)
 	return 0;
 }
 
-long ImageProc::OcrFromFile(const wstring &files, const wstring &color, double sim, std::wstring &retstr)
+long ImageProc::OcrFromFile(const wstring& files, const wstring& color, double sim, std::wstring& retstr)
 {
 	retstr.clear();
 	if (sim < 0. || sim > 1.)
@@ -484,7 +486,7 @@ long ImageProc::OcrFromFile(const wstring &files, const wstring &color, double s
 	return 0;
 }
 
-long ImageProc::OcrAutoFromFile(const wstring &files, double sim, std::wstring &retstr)
+long ImageProc::OcrAutoFromFile(const wstring& files, double sim, std::wstring& retstr)
 {
 	retstr.clear();
 	if (sim < 0. || sim > 1.)
@@ -502,7 +504,7 @@ long ImageProc::OcrAutoFromFile(const wstring &files, double sim, std::wstring &
 	return 0;
 }
 
-long ImageProc::FindLine(const wstring &color, double sim, wstring &retStr)
+long ImageProc::FindLine(const wstring& color, double sim, wstring& retStr)
 {
 	retStr.clear();
 	vector<color_df_t> colors;

+ 16 - 16
gm/gm/imageProc/ImageProc.h

@@ -4,6 +4,7 @@
 #include <map>
 //#include <tesseract/baseapi.h>
 using std::wstring;
+
 /*
 此类为图像处理,包含以下工作
 1.像素比较,查找
@@ -12,11 +13,12 @@ using std::wstring;
 4.简单OCR
 5....
 */
-class ImageProc:public ImageBase
+
+class ImageProc :public ImageBase
 {
 public:
 	const static int _max_dict = 10;
-	
+
 	ImageProc();
 	~ImageProc();
 	//
@@ -24,27 +26,27 @@ public:
 
 	long CmpColor(long x, long y, const std::wstring& scolor, double sim);
 
-	long FindColor(const wstring& color,double sim,long dir, long&x, long&y);
+	long FindColor(const wstring& color, double sim, long dir, long& x, long& y);
 
 	long FindColoEx(const wstring& color, double sim, long dir, wstring& retstr);
 
-	long FindMultiColor(const wstring& first_color,const wstring& offset_color, double sim, long dir, long&x, long&y);
+	long FindMultiColor(const wstring& first_color, const wstring& offset_color, double sim, long dir, long& x, long& y);
 
 	long FindMultiColorEx(const wstring& first_color, const wstring& offset_color, double sim, long dir, wstring& retstr);
 	//图形定位
-	long FindPic(const std::wstring& files,const wstring& delta_colors, double sim,long dir, long& x, long &y);
+	long FindPic(const std::wstring& files, const wstring& delta_colors, double sim, long dir, long& x, long& y);
 	//
 	long FindPicEx(const std::wstring& files, const wstring& delta_colors, double sim, long dir, wstring& retstr, bool returnID = true);
 
-	long FindColorBlock(const wstring&  color, double sim, long count, long height, long width, long& x, long& y);
+	long FindColorBlock(const wstring& color, double sim, long count, long height, long width, long& x, long& y);
 
-	long FindColorBlockEx(const wstring&  color, double sim, long count, long height, long width, wstring& retstr);
+	long FindColorBlockEx(const wstring& color, double sim, long count, long height, long width, wstring& retstr);
 
 	std::wstring GetColor(long x, long y);
 
-	long SetMemDict(int idx, void* data,long size);
+	long SetMemDict(int idx, void* data, long size);
 
-	long SetDict(int idx,const wstring& file);
+	long SetDict(int idx, const wstring& file);
 
 	long UseDict(int idx);
 
@@ -52,18 +54,18 @@ public:
 
 	long OcrEx(const wstring& color, double sim, std::wstring& out_str);
 
-	long FindStr(const wstring& str, const wstring& color, double sim, long& retx,long& rety);
+	long FindStr(const wstring& str, const wstring& color, double sim, long& retx, long& rety);
 
 	long FindStrEx(const wstring& str, const wstring& color, double sim, std::wstring& out_str);
 
 	long OcrAuto(double sim, std::wstring& retstr);
 
-	long OcrFromFile(const wstring& files,const wstring& color, double sim, std::wstring& retstr);
+	long OcrFromFile(const wstring& files, const wstring& color, double sim, std::wstring& retstr);
 
 	long OcrAutoFromFile(const wstring& files, double sim, std::wstring& retstr);
 
 	long FindLine(const wstring& color, double sim, wstring& retStr);
-	
+
 	long LoadPic(const wstring& files);
 
 	long FreePic(const wstring& files);
@@ -74,7 +76,7 @@ private:
 	Dict _dicts[_max_dict];
 	//当前字库索引
 	int _curr_idx;
-	
+
 public:
 	//当前目录
 	wstring _curr_path;
@@ -82,10 +84,8 @@ public:
 	std::map<wstring, Image> _pic_cache;
 	//是否使用图片缓存,默认开启
 	int _enable_cache;
-
 	//tesseract::TessBaseAPI _tes;
-	
-	
+
 private:
 	//RETURN TYPE 0:word colors info; 1:bk color info
 	int str2colordfs(const wstring& color_str, std::vector<color_df_t>& colors);

+ 12 - 12
gm/gm/imageProc/imageView.hpp

@@ -2,22 +2,22 @@
 #define __IMAGE_VIEW_H
 #include "../core/optype.h"
 #include "../include/Image.hpp"
-class imageView {
- private:
-  
 
- public:
-  imageView(ImageBin const& src, rect_t const& block);
-  imageView(imageView const&) = delete;
-  ~imageView();
+class imageView 
+{
+private:
 
-  /* data */
-  const ImageBin& _src;
-  rect_t _block;
+public:
+	imageView(ImageBin const& src, rect_t const& block);
+	imageView(imageView const&) = delete;
+	~imageView();
+
+	/* data */
+	const ImageBin& _src;
+	rect_t _block;
 };
 
-imageView::imageView(ImageBin const& src, rect_t const& block)
-    : _src(src), _block(block) {}
+imageView::imageView(ImageBin const& src, rect_t const& block): _src(src), _block(block) {}
 
 imageView::~imageView() {}
 

+ 136 - 127
gm/gm/libop.cpp

@@ -1,5 +1,4 @@
 // OpInterface.cpp: OpInterface 的实现
-
 #include "libop.h"
 #include "./core/optype.h"
 #include "./core/globalVar.h"
@@ -10,7 +9,6 @@
 #include "./ImageProc/ImageProc.h"
 #include "./core/Cmder.h"
 #include "./winapi/Injecter.h"
-
 #include "./algorithm/AStar.hpp"
 #include "./winapi/MemoryEx.h"
 #include <fstream>
@@ -21,7 +19,6 @@
 #undef FindWindowEx
 #undef SetWindowText
 
-
 const int small_block_size = 10;
 
 libop::libop()
@@ -79,7 +76,7 @@ std::wstring libop::Ver()
 	return _T(OP_VERSION);
 }
 
-void libop::SetPath(const wchar_t *path, long *ret)
+void libop::SetPath(const wchar_t* path, long* ret)
 {
 	wstring fpath = path;
 	replacew(fpath, L"/", L"\\");
@@ -109,39 +106,39 @@ void libop::SetPath(const wchar_t *path, long *ret)
 	}
 }
 
-void libop::GetPath(std::wstring &path)
+void libop::GetPath(std::wstring& path)
 {
 	path = _curr_path;
 }
 
-void libop::GetBasePath(std::wstring &path)
+void libop::GetBasePath(std::wstring& path)
 {
 	path = opEnv::getBasePath();
 }
 
-void libop::GetID(long *ret)
+void libop::GetID(long* ret)
 {
 	*ret = (long)this;
 }
 
-void libop::GetLastError(long *ret)
+void libop::GetLastError(long* ret)
 {
 	*ret = ::GetLastError();
 }
 
-void libop::SetShowErrorMsg(long show_type, long *ret)
+void libop::SetShowErrorMsg(long show_type, long* ret)
 {
 	opEnv::m_showErrorMsg = show_type;
 	*ret = 1;
 }
 
-void libop::Sleep(long millseconds, long *ret)
+void libop::Sleep(long millseconds, long* ret)
 {
 	::Sleep(millseconds);
 	*ret = 1;
 }
 
-void libop::InjectDll(const wchar_t *process_name, const wchar_t *dll_name, long *ret)
+void libop::InjectDll(const wchar_t* process_name, const wchar_t* dll_name, long* ret)
 {
 	auto proc = _ws2string(process_name);
 	auto dll = _ws2string(dll_name);
@@ -161,18 +158,18 @@ void libop::InjectDll(const wchar_t *process_name, const wchar_t *dll_name, long
 	}
 }
 
-void libop::EnablePicCache(long enable, long *ret)
+void libop::EnablePicCache(long enable, long* ret)
 {
 	_image_proc->_enable_cache = enable;
 	*ret = 1;
 }
 
-void libop::CapturePre(const wchar_t *file, LONG *ret)
+void libop::CapturePre(const wchar_t* file, LONG* ret)
 {
 	*ret = _image_proc->Capture(file);
 }
 
-void libop::AStarFindPath(long mapWidth, long mapHeight, const wchar_t *disable_points, long beginX, long beginY, long endX, long endY, std::wstring &path)
+void libop::AStarFindPath(long mapWidth, long mapHeight, const wchar_t* disable_points, long beginX, long beginY, long endX, long endY, std::wstring& path)
 {
 	AStar as;
 	using Vec2i = AStar::Vec2i;
@@ -180,7 +177,7 @@ void libop::AStarFindPath(long mapWidth, long mapHeight, const wchar_t *disable_
 	vector<wstring> vstr;
 	Vec2i tp;
 	split(disable_points, vstr, L"|");
-	for (auto &it : vstr)
+	for (auto& it : vstr)
 	{
 		if (swscanf(it.c_str(), L"%d,%d", &tp.x, &tp.y) != 2)
 			break;
@@ -203,11 +200,11 @@ void libop::AStarFindPath(long mapWidth, long mapHeight, const wchar_t *disable_
 		pathstr.pop_back();
 }
 
-void libop::FindNearestPos(const wchar_t *all_pos, long type, long x, long y, std::wstring &ret)
+void libop::FindNearestPos(const wchar_t* all_pos, long type, long x, long y, std::wstring& ret)
 {
-	const wchar_t *p = 0;
-	wchar_t buf[256] = {0};
-	wchar_t rs[256] = {0};
+	const wchar_t* p = 0;
+	wchar_t buf[256] = { 0 };
+	wchar_t rs[256] = { 0 };
 	double old = 1e9;
 	long rx = -1, ry = -1;
 	std::wstring s = std::regex_replace(all_pos, std::wregex(L","), L" ");
@@ -259,7 +256,7 @@ void libop::FindNearestPos(const wchar_t *all_pos, long type, long x, long y, st
 	ret = rs;
 }
 
-void libop::EnumWindow(long parent, const wchar_t *title, const wchar_t *class_name, long filter, std::wstring &retstr)
+void libop::EnumWindow(long parent, const wchar_t* title, const wchar_t* class_name, long filter, std::wstring& retstr)
 {
 	// TODO: 在此添加实现代码
 	std::unique_ptr<wchar_t> retstring(new wchar_t[MAX_PATH * 200]);
@@ -269,7 +266,7 @@ void libop::EnumWindow(long parent, const wchar_t *title, const wchar_t *class_n
 	retstr = retstring.get();
 }
 
-void libop::EnumWindowByProcess(const wchar_t *process_name, const wchar_t *title, const wchar_t *class_name, long filter, std::wstring &retstring)
+void libop::EnumWindowByProcess(const wchar_t* process_name, const wchar_t* title, const wchar_t* class_name, long filter, std::wstring& retstring)
 {
 	// TODO: 在此添加实现代码
 	std::unique_ptr<wchar_t> retstr(new wchar_t[MAX_PATH * 200]);
@@ -280,7 +277,7 @@ void libop::EnumWindowByProcess(const wchar_t *process_name, const wchar_t *titl
 	retstring = retstr.get();
 }
 
-void libop::EnumProcess(const wchar_t *name, std::wstring &retstring)
+void libop::EnumProcess(const wchar_t* name, std::wstring& retstring)
 {
 	// TODO: 在此添加实现代码
 	std::unique_ptr<wchar_t> retstr(new wchar_t[MAX_PATH * 200]);
@@ -290,88 +287,88 @@ void libop::EnumProcess(const wchar_t *name, std::wstring &retstring)
 	retstring = retstr.get();
 }
 
-void libop::ClientToScreen(long ClientToScreen, long *x, long *y, long *bret)
+void libop::ClientToScreen(long ClientToScreen, long* x, long* y, long* bret)
 {
 	// TODO: 在此添加实现代码
 
 	*bret = _winapi->ClientToScreen(ClientToScreen, *x, *y);
 }
 
-void libop::FindWindow(const wchar_t *class_name, const wchar_t *title, long *rethwnd)
+void libop::FindWindow(const wchar_t* class_name, const wchar_t* title, long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	*rethwnd = _winapi->FindWindow(class_name, title);
 }
 
-void libop::FindWindowByProcess(const wchar_t *process_name, const wchar_t *class_name, const wchar_t *title, long *rethwnd)
+void libop::FindWindowByProcess(const wchar_t* process_name, const wchar_t* class_name, const wchar_t* title, long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	_winapi->FindWindowByProcess(class_name, title, *rethwnd, process_name);
 }
 
-void libop::FindWindowByProcessId(long process_id, const wchar_t *class_name, const wchar_t *title, long *rethwnd)
+void libop::FindWindowByProcessId(long process_id, const wchar_t* class_name, const wchar_t* title, long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	_winapi->FindWindowByProcess(class_name, title, *rethwnd, NULL, process_id);
 }
 
-void libop::FindWindowEx(long parent, const wchar_t *class_name, const wchar_t *title, long *rethwnd)
+void libop::FindWindowEx(long parent, const wchar_t* class_name, const wchar_t* title, long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	*rethwnd = _winapi->FindWindowEx(parent, class_name, title);
 }
 
-void libop::GetClientRect(long hwnd, long *x1, long *y1, long *x2, long *y2, long *nret)
+void libop::GetClientRect(long hwnd, long* x1, long* y1, long* x2, long* y2, long* nret)
 {
 	// TODO: 在此添加实现代码
 
 	*nret = _winapi->GetClientRect(hwnd, *x1, *y1, *x2, *y2);
 }
 
-void libop::GetClientSize(long hwnd, long *width, long *height, long *nret)
+void libop::GetClientSize(long hwnd, long* width, long* height, long* nret)
 {
 	// TODO: 在此添加实现代码
 
 	*nret = _winapi->GetClientSize(hwnd, *width, *height);
 }
 
-void libop::GetForegroundFocus(long *rethwnd)
+void libop::GetForegroundFocus(long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	*rethwnd = (LONG)::GetFocus();
 }
 
-void libop::GetForegroundWindow(long *rethwnd)
+void libop::GetForegroundWindow(long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	*rethwnd = (LONG)::GetForegroundWindow();
 }
 
-void libop::GetMousePointWindow(long *rethwnd)
+void libop::GetMousePointWindow(long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	//::Sleep(2000);
 	_winapi->GetMousePointWindow(*rethwnd);
 }
 
-void libop::GetPointWindow(long x, long y, long *rethwnd)
+void libop::GetPointWindow(long x, long y, long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	_winapi->GetMousePointWindow(*rethwnd, x, y);
 }
 
-void libop::GetProcessInfo(long pid, std::wstring &retstring)
+void libop::GetProcessInfo(long pid, std::wstring& retstring)
 {
 	// TODO: 在此添加实现代码
 
-	wchar_t retstr[MAX_PATH] = {0};
+	wchar_t retstr[MAX_PATH] = { 0 };
 	_winapi->GetProcessInfo(pid, retstr);
 	//* retstring=_bstr_t(retstr);
 
 	retstring = retstr;
 }
 
-void libop::GetSpecialWindow(long flag, long *rethwnd)
+void libop::GetSpecialWindow(long flag, long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	*rethwnd = 0;
@@ -383,23 +380,23 @@ void libop::GetSpecialWindow(long flag, long *rethwnd)
 	}
 }
 
-void libop::GetWindow(long hwnd, long flag, long *nret)
+void libop::GetWindow(long hwnd, long flag, long* nret)
 {
 	// TODO: 在此添加实现代码
 	_winapi->GetWindow(hwnd, flag, *nret);
 }
 
-void libop::GetWindowClass(long hwnd, std::wstring &retstring)
+void libop::GetWindowClass(long hwnd, std::wstring& retstring)
 {
 	// TODO: 在此添加实现代码
-	wchar_t classname[MAX_PATH] = {0};
+	wchar_t classname[MAX_PATH] = { 0 };
 	::GetClassName((HWND)hwnd, classname, MAX_PATH);
 	//* retstring=_bstr_t(classname);
 
 	retstring = classname;
 }
 
-void libop::GetWindowProcessId(long hwnd, long *nretpid)
+void libop::GetWindowProcessId(long hwnd, long* nretpid)
 {
 	// TODO: 在此添加实现代码
 	DWORD pid = 0;
@@ -407,22 +404,21 @@ void libop::GetWindowProcessId(long hwnd, long *nretpid)
 	*nretpid = pid;
 }
 
-void libop::GetWindowProcessPath(long hwnd, std::wstring &retstring)
+void libop::GetWindowProcessPath(long hwnd, std::wstring& retstring)
 {
 	// TODO: 在此添加实现代码
 	DWORD pid = 0;
 	::GetWindowThreadProcessId((HWND)hwnd, &pid);
-	wchar_t process_path[MAX_PATH] = {0};
+	wchar_t process_path[MAX_PATH] = { 0 };
 	_winapi->GetProcesspath(pid, process_path);
 	//* retstring=_bstr_t(process_path);
 
 	retstring = process_path;
 }
 
-void libop::GetWindowRect(long hwnd, long *x1, long *y1, long *x2, long *y2, long *nret)
+void libop::GetWindowRect(long hwnd, long* x1, long* y1, long* x2, long* y2, long* nret)
 {
 	// TODO: 在此添加实现代码
-
 	RECT winrect;
 	*nret = ::GetWindowRect((HWND)hwnd, &winrect);
 	*x1 = winrect.left;
@@ -431,23 +427,23 @@ void libop::GetWindowRect(long hwnd, long *x1, long *y1, long *x2, long *y2, lon
 	*y2 = winrect.bottom;
 }
 
-void libop::GetWindowState(long hwnd, long flag, long *rethwnd)
+void libop::GetWindowState(long hwnd, long flag, long* rethwnd)
 {
 	// TODO: 在此添加实现代码
 	*rethwnd = _winapi->GetWindowState(hwnd, flag);
 }
 
-void libop::GetWindowTitle(long hwnd, std::wstring &rettitle)
+void libop::GetWindowTitle(long hwnd, std::wstring& rettitle)
 {
 	// TODO: 在此添加实现代码
-	wchar_t title[MAX_PATH] = {0};
+	wchar_t title[MAX_PATH] = { 0 };
 	::GetWindowTextW((HWND)hwnd, title, MAX_PATH);
 	//* rettitle=_bstr_t(title);
 
 	rettitle = title;
 }
 
-void libop::MoveWindow(long hwnd, long x, long y, long *nret)
+void libop::MoveWindow(long hwnd, long x, long y, long* nret)
 {
 	// TODO: 在此添加实现代码
 	RECT winrect;
@@ -457,7 +453,7 @@ void libop::MoveWindow(long hwnd, long x, long y, long *nret)
 	*nret = ::MoveWindow((HWND)hwnd, x, y, width, hight, false);
 }
 
-void libop::ScreenToClient(long hwnd, long *x, long *y, long *nret)
+void libop::ScreenToClient(long hwnd, long* x, long* y, long* nret)
 {
 	// TODO: 在此添加实现代码
 
@@ -467,65 +463,65 @@ void libop::ScreenToClient(long hwnd, long *x, long *y, long *nret)
 	*y = point.y;
 }
 
-void libop::SendPaste(long hwnd, long *nret)
+void libop::SendPaste(long hwnd, long* nret)
 {
 	// TODO: 在此添加实现代码
 	*nret = _winapi->SendPaste(hwnd);
 }
 
-void libop::SetClientSize(long hwnd, long width, long hight, long *nret)
+void libop::SetClientSize(long hwnd, long width, long hight, long* nret)
 {
 	// TODO: 在此添加实现代码
 	*nret = _winapi->SetWindowSize(hwnd, width, hight);
 }
 
-void libop::SetWindowState(long hwnd, long flag, long *nret)
+void libop::SetWindowState(long hwnd, long flag, long* nret)
 {
 	// TODO: 在此添加实现代码
 	*nret = _winapi->SetWindowState(hwnd, flag);
 }
 
-void libop::SetWindowSize(long hwnd, long width, long height, long *nret)
+void libop::SetWindowSize(long hwnd, long width, long height, long* nret)
 {
 	// TODO: 在此添加实现代码
 	*nret = _winapi->SetWindowSize(hwnd, width, height, 1);
 }
 
-void libop::SetWindowText(long hwnd, const wchar_t *title, long *nret)
+void libop::SetWindowText(long hwnd, const wchar_t* title, long* nret)
 {
 	// TODO: 在此添加实现代码
 	//*nret=gWindowObj.TSSetWindowState(hwnd,flag);
 	*nret = ::SetWindowTextW((HWND)hwnd, title);
 }
 
-void libop::SetWindowTransparent(long hwnd, long trans, long *nret)
+void libop::SetWindowTransparent(long hwnd, long trans, long* nret)
 {
 	// TODO: 在此添加实现代码
 	*nret = _winapi->SetWindowTransparent(hwnd, trans);
 }
 
-void libop::SendString(long hwnd, const wchar_t *str, long *ret)
+void libop::SendString(long hwnd, const wchar_t* str, long* ret)
 {
 	*ret = _winapi->SendString((HWND)hwnd, str);
 }
 
-void libop::SendStringIme(long hwnd, const wchar_t *str, long *ret)
+void libop::SendStringIme(long hwnd, const wchar_t* str, long* ret)
 {
 	*ret = _winapi->SendStringIme((HWND)hwnd, str);
 }
 
-void libop::RunApp(const wchar_t *cmdline, long mode, long *ret)
+void libop::RunApp(const wchar_t* cmdline, long mode, long* ret)
 {
 	*ret = _winapi->RunApp(cmdline, mode);
 }
 
-void libop::WinExec(const wchar_t *cmdline, long cmdshow, long *ret)
+void libop::WinExec(const wchar_t* cmdline, long cmdshow, long* ret)
 {
 	auto str = _ws2string(cmdline);
 	*ret = ::WinExec(str.c_str(), cmdshow) > 31 ? 1 : 0;
 }
 
-void libop::GetCmdStr(const wchar_t *cmd, long millseconds, std::wstring &retstr)
+void libop::GetCmdStr(const wchar_t* cmd, long millseconds, std::wstring& retstr)
 {
 	auto strcmd = _ws2string(cmd);
 	Cmder cd;
@@ -533,7 +529,7 @@ void libop::GetCmdStr(const wchar_t *cmd, long millseconds, std::wstring &retstr
 	retstr = _s2wstring(str);
 }
 
-void libop::BindWindow(long hwnd, const wchar_t *display, const wchar_t *mouse, const wchar_t *keypad, long mode, long *ret)
+void libop::BindWindow(long hwnd, const wchar_t* display, const wchar_t* mouse, const wchar_t* keypad, long mode, long* ret)
 {
 	if (_bkproc->IsBind())
 		_bkproc->UnBindWindow();
@@ -544,103 +540,103 @@ void libop::BindWindow(long hwnd, const wchar_t *display, const wchar_t *mouse,
 	}
 }
 
-void libop::UnBindWindow(long *ret)
+void libop::UnBindWindow(long* ret)
 {
 	*ret = _bkproc->UnBindWindow();
 }
 
-void libop::GetCursorPos(long *x, long *y, long *ret)
+void libop::GetCursorPos(long* x, long* y, long* ret)
 {
 
 	*ret = _bkproc->_bkmouse->GetCursorPos(*x, *y);
 }
 
-void libop::MoveR(long x, long y, long *ret)
+void libop::MoveR(long x, long y, long* ret)
 {
 	*ret = _bkproc->_bkmouse->MoveR(x, y);
 }
 //把鼠标移动到目的点(x,y)
-void libop::MoveTo(long x, long y, long *ret)
+void libop::MoveTo(long x, long y, long* ret)
 {
 	*ret = _bkproc->_bkmouse->MoveTo(x, y);
 }
 
-void libop::MoveToEx(long x, long y, long w, long h, long *ret)
+void libop::MoveToEx(long x, long y, long w, long h, long* ret)
 {
 	*ret = _bkproc->_bkmouse->MoveToEx(x, y, w, h);
 }
 
-void libop::LeftClick(long *ret)
+void libop::LeftClick(long* ret)
 {
 	*ret = _bkproc->_bkmouse->LeftClick();
 }
 
-void libop::LeftDoubleClick(long *ret)
+void libop::LeftDoubleClick(long* ret)
 {
 	*ret = _bkproc->_bkmouse->LeftDoubleClick();
 }
 
-void libop::LeftDown(long *ret)
+void libop::LeftDown(long* ret)
 {
 	*ret = _bkproc->_bkmouse->LeftDown();
 }
 
-void libop::LeftUp(long *ret)
+void libop::LeftUp(long* ret)
 {
 	*ret = _bkproc->_bkmouse->LeftUp();
 }
 
-void libop::MiddleClick(long *ret)
+void libop::MiddleClick(long* ret)
 {
 	*ret = _bkproc->_bkmouse->MiddleClick();
 }
 
-void libop::MiddleDown(long *ret)
+void libop::MiddleDown(long* ret)
 {
 	*ret = _bkproc->_bkmouse->MiddleDown();
 }
 
-void libop::MiddleUp(long *ret)
+void libop::MiddleUp(long* ret)
 {
 	*ret = _bkproc->_bkmouse->MiddleUp();
 }
 
-void libop::RightClick(long *ret)
+void libop::RightClick(long* ret)
 {
 	*ret = _bkproc->_bkmouse->RightClick();
 }
 
-void libop::RightDown(long *ret)
+void libop::RightDown(long* ret)
 {
 	*ret = _bkproc->_bkmouse->RightDown();
 }
 
-void libop::RightUp(long *ret)
+void libop::RightUp(long* ret)
 {
 	*ret = _bkproc->_bkmouse->RightUp();
 }
 
-void libop::WheelDown(long *ret)
+void libop::WheelDown(long* ret)
 {
 	*ret = _bkproc->_bkmouse->WheelDown();
 }
 
-void libop::WheelUp(long *ret)
+void libop::WheelUp(long* ret)
 {
 	*ret = _bkproc->_bkmouse->WheelUp();
 }
 
-void libop::GetKeyState(long vk_code, long *ret)
+void libop::GetKeyState(long vk_code, long* ret)
 {
 	*ret = _bkproc->_keypad->GetKeyState(vk_code);
 }
 
-void libop::KeyDown(long vk_code, long *ret)
+void libop::KeyDown(long vk_code, long* ret)
 {
 	*ret = _bkproc->_keypad->KeyDown(vk_code);
 }
 
-void libop::KeyDownChar(const wchar_t *vk_code, long *ret)
+void libop::KeyDownChar(const wchar_t* vk_code, long* ret)
 {
 	auto nlen = wcslen(vk_code);
 	*ret = 0;
@@ -653,12 +649,12 @@ void libop::KeyDownChar(const wchar_t *vk_code, long *ret)
 	}
 }
 
-void libop::KeyUp(long vk_code, long *ret)
+void libop::KeyUp(long vk_code, long* ret)
 {
 	*ret = _bkproc->_keypad->KeyUp(vk_code);
 }
 
-void libop::KeyUpChar(const wchar_t *vk_code, long *ret)
+void libop::KeyUpChar(const wchar_t* vk_code, long* ret)
 {
 	auto nlen = wcslen(vk_code);
 	*ret = 0;
@@ -671,20 +667,20 @@ void libop::KeyUpChar(const wchar_t *vk_code, long *ret)
 	}
 }
 
-void libop::WaitKey(long vk_code, long time_out, long *ret)
+void libop::WaitKey(long vk_code, long time_out, long* ret)
 {
 	if (time_out < 0)
 		time_out = 0;
 	*ret = _bkproc->_keypad->WaitKey(vk_code, time_out);
 }
 
-void libop::KeyPress(long vk_code, long *ret)
+void libop::KeyPress(long vk_code, long* ret)
 {
 
 	*ret = _bkproc->_keypad->KeyPress(vk_code);
 }
 
-void libop::KeyPressChar(const wchar_t *vk_code, long *ret)
+void libop::KeyPressChar(const wchar_t* vk_code, long* ret)
 {
 	auto nlen = wcslen(vk_code);
 	*ret = 0;
@@ -699,7 +695,7 @@ void libop::KeyPressChar(const wchar_t *vk_code, long *ret)
 }
 
 //抓取指定区域(x1, y1, x2, y2)的图像, 保存为file
-void libop::Capture(long x1, long y1, long x2, long y2, const wchar_t *file_name, long *ret)
+void libop::Capture(long x1, long y1, long x2, long y2, const wchar_t* file_name, long* ret)
 {
 
 	*ret = 0;
@@ -718,8 +714,9 @@ void libop::Capture(long x1, long y1, long x2, long y2, const wchar_t *file_name
 		}
 	}
 }
+
 //比较指定坐标点(x,y)的颜色
-void libop::CmpColor(long x, long y, const wchar_t *color, DOUBLE sim, long *ret)
+void libop::CmpColor(long x, long y, const wchar_t* color, DOUBLE sim, long* ret)
 {
 	//LONG rx = -1, ry = -1;
 	long tx = x + small_block_size, ty = y + small_block_size;
@@ -737,8 +734,9 @@ void libop::CmpColor(long x, long y, const wchar_t *color, DOUBLE sim, long *ret
 		}
 	}
 }
+
 //查找指定区域内的颜色
-void libop::FindColor(long x1, long y1, long x2, long y2, const wchar_t *color, DOUBLE sim, long dir, long *x, long *y, long *ret)
+void libop::FindColor(long x1, long y1, long x2, long y2, const wchar_t* color, DOUBLE sim, long dir, long* x, long* y, long* ret)
 {
 
 	*ret = 0;
@@ -757,8 +755,9 @@ void libop::FindColor(long x1, long y1, long x2, long y2, const wchar_t *color,
 		}
 	}
 }
+
 //查找指定区域内的所有颜色
-void libop::FindColorEx(long x1, long y1, long x2, long y2, const wchar_t *color, DOUBLE sim, long dir, std::wstring &retstr)
+void libop::FindColorEx(long x1, long y1, long x2, long y2, const wchar_t* color, DOUBLE sim, long dir, std::wstring& retstr)
 {
 	//wstring str;
 	retstr.clear();
@@ -774,10 +773,11 @@ void libop::FindColorEx(long x1, long y1, long x2, long y2, const wchar_t *color
 			_image_proc->FindColoEx(color, sim, dir, retstr);
 		}
 	}
-	
+
 }
+
 //根据指定的多点查找颜色坐标
-void libop::FindMultiColor(long x1, long y1, long x2, long y2, const wchar_t *first_color, const wchar_t *offset_color, DOUBLE sim, long dir, long *x, long *y, long *ret)
+void libop::FindMultiColor(long x1, long y1, long x2, long y2, const wchar_t* first_color, const wchar_t* offset_color, DOUBLE sim, long dir, long* x, long* y, long* ret)
 {
 
 	*ret = 0;
@@ -802,8 +802,9 @@ void libop::FindMultiColor(long x1, long y1, long x2, long y2, const wchar_t *fi
 		}*/
 	}
 }
+
 //根据指定的多点查找所有颜色坐标
-void libop::FindMultiColorEx(long x1, long y1, long x2, long y2, const wchar_t *first_color, const wchar_t *offset_color, DOUBLE sim, long dir, std::wstring &retstr)
+void libop::FindMultiColorEx(long x1, long y1, long x2, long y2, const wchar_t* first_color, const wchar_t* offset_color, DOUBLE sim, long dir, std::wstring& retstr)
 {
 	retstr.clear();
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -820,8 +821,9 @@ void libop::FindMultiColorEx(long x1, long y1, long x2, long y2, const wchar_t *
 	}
 	//retstr = str;
 }
+
 //查找指定区域内的图片
-void libop::FindPic(long x1, long y1, long x2, long y2, const wchar_t *files, const wchar_t *delta_color, DOUBLE sim, long dir, long *x, long *y, long *ret)
+void libop::FindPic(long x1, long y1, long x2, long y2, const wchar_t* files, const wchar_t* delta_color, DOUBLE sim, long dir, long* x, long* y, long* ret)
 {
 
 	*ret = 0;
@@ -846,8 +848,9 @@ void libop::FindPic(long x1, long y1, long x2, long y2, const wchar_t *files, co
 		}*/
 	}
 }
+
 //查找多个图片
-void libop::FindPicEx(long x1, long y1, long x2, long y2, const wchar_t *files, const wchar_t *delta_color, DOUBLE sim, long dir, std::wstring &retstr)
+void libop::FindPicEx(long x1, long y1, long x2, long y2, const wchar_t* files, const wchar_t* delta_color, DOUBLE sim, long dir, std::wstring& retstr)
 {
 
 	//wstring str;
@@ -866,7 +869,7 @@ void libop::FindPicEx(long x1, long y1, long x2, long y2, const wchar_t *files,
 	//retstr = str;
 }
 
-void libop::FindPicExS(long x1, long y1, long x2, long y2, const wchar_t *files, const wchar_t *delta_color, double sim, long dir, std::wstring &retstr)
+void libop::FindPicExS(long x1, long y1, long x2, long y2, const wchar_t* files, const wchar_t* delta_color, double sim, long dir, std::wstring& retstr)
 {
 	//wstring str;
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -884,7 +887,7 @@ void libop::FindPicExS(long x1, long y1, long x2, long y2, const wchar_t *files,
 	//retstr = str;
 }
 
-void libop::FindColorBlock(long x1, long y1, long x2, long y2, const wchar_t *color, double sim, long count, long height, long width, long *x, long *y, long *ret)
+void libop::FindColorBlock(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, long count, long height, long width, long* x, long* y, long* ret)
 {
 	*ret = 0;
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -901,7 +904,7 @@ void libop::FindColorBlock(long x1, long y1, long x2, long y2, const wchar_t *co
 	}
 }
 
-void libop::FindColorBlockEx(long x1, long y1, long x2, long y2, const wchar_t *color, double sim, long count, long height, long width, std::wstring &retstr)
+void libop::FindColorBlockEx(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, long count, long height, long width, std::wstring& retstr)
 {
 
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -919,7 +922,7 @@ void libop::FindColorBlockEx(long x1, long y1, long x2, long y2, const wchar_t *
 }
 
 //获取(x,y)的颜色
-void libop::GetColor(long x, long y, std::wstring &ret)
+void libop::GetColor(long x, long y, std::wstring& ret)
 {
 	color_t cr;
 	auto tx = x + small_block_size, ty = y + small_block_size;
@@ -943,31 +946,31 @@ void libop::GetColor(long x, long y, std::wstring &ret)
 	ret = cr.towstr();
 }
 
-void libop::SetDisplayInput(const wchar_t *mode, long *ret)
+void libop::SetDisplayInput(const wchar_t* mode, long* ret)
 {
 	*ret = _bkproc->set_display_method(mode);
 }
 
-void libop::LoadPic(const wchar_t *file_name, long *ret)
+void libop::LoadPic(const wchar_t* file_name, long* ret)
 {
 	*ret = _image_proc->LoadPic(file_name);
 }
 
-void libop::FreePic(const wchar_t *file_name, long *ret)
+void libop::FreePic(const wchar_t* file_name, long* ret)
 {
 	*ret = _image_proc->FreePic(file_name);
 }
 
-void libop::LoadMemPic(const wchar_t *file_name, void *data, long size, long *ret)
+void libop::LoadMemPic(const wchar_t* file_name, void* data, long size, long* ret)
 {
 	*ret = _image_proc->LoadMemPic(file_name, data, size);
 }
 
-void libop::GetScreenData(long x1, long y1, long x2, long y2, void **data, long *ret)
+void libop::GetScreenData(long x1, long y1, long x2, long y2, void** data, long* ret)
 {
 	*data = nullptr;
 	*ret = 0;
-	auto &img = _image_proc->_src;
+	auto& img = _image_proc->_src;
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
 	{
 		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
@@ -989,7 +992,7 @@ void libop::GetScreenData(long x1, long y1, long x2, long y2, void **data, long
 	}
 }
 
-void libop::GetScreenDataBmp(long x1, long y1, long x2, long y2, void **data, long *size, long *ret)
+void libop::GetScreenDataBmp(long x1, long y1, long x2, long y2, void** data, long* size, long* ret)
 {
 	*data = 0;
 	*ret = 0;
@@ -1002,10 +1005,10 @@ void libop::GetScreenDataBmp(long x1, long y1, long x2, long y2, void **data, lo
 		else
 		{
 			_image_proc->set_offset(x1, y1);
-			auto &img = _image_proc->_src;
+			auto& img = _image_proc->_src;
 
-			BITMAPFILEHEADER bfh = {0}; //bmp file header
-			BITMAPINFOHEADER bih = {0}; //bmp info header
+			BITMAPFILEHEADER bfh = { 0 }; //bmp file header
+			BITMAPINFOHEADER bih = { 0 }; //bmp info header
 			const int szBfh = sizeof(BITMAPFILEHEADER);
 			const int szBih = sizeof(BITMAPINFOHEADER);
 			bfh.bfOffBits = szBfh + szBih;
@@ -1029,7 +1032,7 @@ void libop::GetScreenDataBmp(long x1, long y1, long x2, long y2, void **data, lo
 			f.write((char*)&bih, sizeof(bih));
 			f.write((char*)img.pdata, img.size() * 4);
 		}
-		
+
 		f.close();*/
 			auto dst = _screenDataBmp.data();
 
@@ -1048,7 +1051,7 @@ void libop::GetScreenDataBmp(long x1, long y1, long x2, long y2, void **data, lo
 	}
 }
 
-void libop::GetScreenFrameInfo(long *frame_id, long *time)
+void libop::GetScreenFrameInfo(long* frame_id, long* time)
 {
 	FrameInfo info = {};
 	if (_bkproc->IsBind())
@@ -1059,7 +1062,7 @@ void libop::GetScreenFrameInfo(long *frame_id, long *time)
 	*time = info.time;
 }
 
-void libop::MatchPicName(const wchar_t *pic_name, std::wstring &retstr)
+void libop::MatchPicName(const wchar_t* pic_name, std::wstring& retstr)
 {
 	retstr.clear();
 	std::wstring s(pic_name);
@@ -1084,7 +1087,7 @@ void libop::MatchPicName(const wchar_t *pic_name, std::wstring &retstr)
 		fs::directory_iterator iter(path);
 		std::wstring tmp;
 		std::wregex e(s);
-		for (auto &it : iter)
+		for (auto& it : iter)
 		{
 			if (it.status().type() == fs::file_type::regular)
 			{
@@ -1109,24 +1112,25 @@ void libop::MatchPicName(const wchar_t *pic_name, std::wstring &retstr)
 }
 
 //设置字库文件
-void libop::SetDict(long idx, const wchar_t *file_name, long *ret)
+void libop::SetDict(long idx, const wchar_t* file_name, long* ret)
 {
 	*ret = _image_proc->SetDict(idx, file_name);
 }
 
 //设置内存字库文件
-void libop::SetMemDict(long idx, const wchar_t *data, long size, long *ret)
+void libop::SetMemDict(long idx, const wchar_t* data, long size, long* ret)
 {
-	*ret = _image_proc->SetMemDict(idx, (void *)data, size);
+	*ret = _image_proc->SetMemDict(idx, (void*)data, size);
 }
 
 //使用哪个字库文件进行识别
-void libop::UseDict(long idx, long *ret)
+void libop::UseDict(long idx, long* ret)
 {
 	*ret = _image_proc->UseDict(idx);
 }
+
 //识别屏幕范围(x1,y1,x2,y2)内符合color_format的字符串,并且相似度为sim,sim取值范围(0.1-1.0),
-void libop::Ocr(long x1, long y1, long x2, long y2, const wchar_t *color, DOUBLE sim, std::wstring &retstr)
+void libop::Ocr(long x1, long y1, long x2, long y2, const wchar_t* color, DOUBLE sim, std::wstring& retstr)
 {
 	wstring str;
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -1143,8 +1147,9 @@ void libop::Ocr(long x1, long y1, long x2, long y2, const wchar_t *color, DOUBLE
 	}
 	retstr = str;
 }
+
 //回识别到的字符串,以及每个字符的坐标.
-void libop::OcrEx(long x1, long y1, long x2, long y2, const wchar_t *color, DOUBLE sim, std::wstring &retstr)
+void libop::OcrEx(long x1, long y1, long x2, long y2, const wchar_t* color, DOUBLE sim, std::wstring& retstr)
 {
 	wstring str;
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -1161,8 +1166,9 @@ void libop::OcrEx(long x1, long y1, long x2, long y2, const wchar_t *color, DOUB
 	}
 	retstr = str;
 }
+
 //在屏幕范围(x1,y1,x2,y2)内,查找string(可以是任意个字符串的组合),并返回符合color_format的坐标位置
-void libop::FindStr(long x1, long y1, long x2, long y2, const wchar_t *strs, const wchar_t *color, DOUBLE sim, long *retx, long *rety, long *ret)
+void libop::FindStr(long x1, long y1, long x2, long y2, const wchar_t* strs, const wchar_t* color, DOUBLE sim, long* retx, long* rety, long* ret)
 {
 	wstring str;
 	*retx = *rety = -1;
@@ -1179,8 +1185,9 @@ void libop::FindStr(long x1, long y1, long x2, long y2, const wchar_t *strs, con
 		}
 	}
 }
+
 //返回符合color_format的所有坐标位置
-void libop::FindStrEx(long x1, long y1, long x2, long y2, const wchar_t *strs, const wchar_t *color, DOUBLE sim, std::wstring &retstr)
+void libop::FindStrEx(long x1, long y1, long x2, long y2, const wchar_t* strs, const wchar_t* color, DOUBLE sim, std::wstring& retstr)
 {
 	wstring str;
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -1198,7 +1205,7 @@ void libop::FindStrEx(long x1, long y1, long x2, long y2, const wchar_t *strs, c
 	retstr = str;
 }
 
-void libop::OcrAuto(long x1, long y1, long x2, long y2, DOUBLE sim, std::wstring &retstr)
+void libop::OcrAuto(long x1, long y1, long x2, long y2, DOUBLE sim, std::wstring& retstr)
 {
 	wstring str;
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
@@ -1217,21 +1224,22 @@ void libop::OcrAuto(long x1, long y1, long x2, long y2, DOUBLE sim, std::wstring
 }
 
 //从文件中识别图片
-void libop::OcrFromFile(const wchar_t *file_name, const wchar_t *color_format, DOUBLE sim, std::wstring &retstr)
+void libop::OcrFromFile(const wchar_t* file_name, const wchar_t* color_format, DOUBLE sim, std::wstring& retstr)
 {
 	wstring str;
 	_image_proc->OcrFromFile(file_name, color_format, sim, str);
 	retstr = str;
 }
+
 //从文件中识别图片,无需指定颜色
-void libop::OcrAutoFromFile(const wchar_t *file_name, DOUBLE sim, std::wstring &retstr)
+void libop::OcrAutoFromFile(const wchar_t* file_name, DOUBLE sim, std::wstring& retstr)
 {
 	wstring str;
 	_image_proc->OcrAutoFromFile(file_name, sim, str);
 	retstr = str;
 }
 
-void libop::FindLine(long x1, long y1, long x2, long y2, const wchar_t *color, double sim, wstring &retstr)
+void libop::FindLine(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, wstring& retstr)
 {
 	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
 	{
@@ -1247,14 +1255,15 @@ void libop::FindLine(long x1, long y1, long x2, long y2, const wchar_t *color, d
 	}
 }
 
-void libop::WriteData(long hwnd, const wchar_t *address, const wchar_t *data, long size, long *ret)
+void libop::WriteData(long hwnd, const wchar_t* address, const wchar_t* data, long size, long* ret)
 {
 	*ret = 0;
 	MemoryEx mem;
 	*ret = mem.WriteData((HWND)hwnd, address, data, size);
 }
+
 //读取数据
-void libop::ReadData(long hwnd, const wchar_t *address, long size, std::wstring &retstr)
+void libop::ReadData(long hwnd, const wchar_t* address, long size, std::wstring& retstr)
 {
 	MemoryEx mem;
 	retstr = mem.ReadData((HWND)hwnd, address, size);

+ 28 - 32
gm/gm/libop.h

@@ -29,19 +29,16 @@ using bytearray = std::vector<unsigned char>;
 #undef FindWindowEx
 #undef SetWindowText
 
-
-
-class OP_API libop{
-	
+class OP_API libop 
+{
 public:
-	
 	libop();
 	~libop();
 	//复制构造
 	libop(libop const&) = delete;
 	libop& operator=(libop const rhs) = delete;
 private:
-	
+
 	//一些共用变量
 
 	//1. Windows API
@@ -52,7 +49,7 @@ private:
 	ImageProc* _image_proc;
 	// work path
 	std::wstring _curr_path;
-	
+
 	std::map<std::wstring, long> _vkmap;
 	bytearray _screenData;
 	bytearray _screenDataBmp;
@@ -74,19 +71,19 @@ public:
 	void GetLastError(long* ret);
 	//设置是否弹出错误信息,默认是打开 0:关闭,1:显示为信息框,2:保存到文件,3:输出到标准输出
 	void SetShowErrorMsg(long show_type, long* ret);
-	
+
 	//sleep
 	void Sleep(long millseconds, long* ret);
 	//Process
 	//inject dll
-	void InjectDll(const wchar_t* process_name,const wchar_t* dll_name, long* ret);
+	void InjectDll(const wchar_t* process_name, const wchar_t* dll_name, long* ret);
 	//设置是否开启或者关闭插件内部的图片缓存机制
 	void EnablePicCache(long enable, long* ret);
 	//取上次操作的图色区域,保存为file(24位位图)
 	void CapturePre(const wchar_t* file_name, long* ret);
 	//---------------------algorithm-------------------------------
 	//A星算法
-	void AStarFindPath(long mapWidth,long mapHeight,const wchar_t* disable_points,long beginX,long beginY, long endX,long endY,std::wstring& ret);
+	void AStarFindPath(long mapWidth, long mapHeight, const wchar_t* disable_points, long beginX, long beginY, long endX, long endY, std::wstring& ret);
 	//
 	void FindNearestPos(const wchar_t* all_pos, long type, long x, long y, std::wstring& ret);
 	//--------------------windows api------------------------------
@@ -162,11 +159,11 @@ public:
 	void WinExec(const wchar_t* cmdline, long cmdshow, long* ret);
 
 	//运行命令行并返回结果
-	void GetCmdStr(const wchar_t* cmd,long millseconds, std::wstring& retstr);
+	void GetCmdStr(const wchar_t* cmd, long millseconds, std::wstring& retstr);
 
 	//--------------------Background -----------------------
 	//bind window and beign capture screen
-	void BindWindow(long hwnd, const wchar_t* display, const wchar_t* mouse, const wchar_t* keypad, long mode,long *ret);
+	void BindWindow(long hwnd, const wchar_t* display, const wchar_t* mouse, const wchar_t* keypad, long mode, long* ret);
 	//
 	void UnBindWindow(long* ret);
 	//--------------------mouse & keyboard------------------
@@ -177,7 +174,7 @@ public:
 	//把鼠标移动到目的点(x,y)
 	void MoveTo(long x, long y, long* ret);
 	//把鼠标移动到目的范围内的任意一点
-	void MoveToEx(long x, long y,long w,long h, long* ret);
+	void MoveToEx(long x, long y, long w, long h, long* ret);
 	//按下鼠标左键
 	void LeftClick(long* ret);
 	//双击鼠标左键
@@ -213,7 +210,7 @@ public:
 	//弹起来虚拟键vk_code
 	void KeyUpChar(const wchar_t* vk_code, long* ret);
 	//等待指定的按键按下 (前台,不是后台)
-	void WaitKey(long vk_code,long time_out, long* ret);
+	void WaitKey(long vk_code, long time_out, long* ret);
 	//发送字符串
 	//long SendString(long HWND)
 	//弹起来虚拟键vk_code
@@ -224,26 +221,26 @@ public:
 	//抓取指定区域(x1, y1, x2, y2)的图像, 保存为file
 	void Capture(long x1, long y1, long x2, long y2, const wchar_t* file_name, long* ret);
 	//比较指定坐标点(x,y)的颜色
-	void CmpColor(long x, long y,const wchar_t* color,double sim, long* ret);
+	void CmpColor(long x, long y, const wchar_t* color, double sim, long* ret);
 	//查找指定区域内的颜色
-	void FindColor(long x1, long y1, long x2, long y2, const wchar_t* color,double sim,long dir, long* x, long* y, long* ret);
+	void FindColor(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, long dir, long* x, long* y, long* ret);
 	//查找指定区域内的所有颜色
-	void FindColorEx(long x1, long y1, long x2, long y2, const wchar_t* color, double sim,long dir, std::wstring& retstr);
+	void FindColorEx(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, long dir, std::wstring& retstr);
 	//根据指定的多点查找颜色坐标
 	void FindMultiColor(long x1, long y1, long x2, long y2, const wchar_t* first_color, const wchar_t* offset_color, double sim, long dir, long* x, long* y, long* ret);
 	//根据指定的多点查找所有颜色坐标
-	void FindMultiColorEx(long x1, long y1, long x2, long y2, const wchar_t* first_color, const wchar_t* offset_color, double sim, long dir,std::wstring& retstr);
+	void FindMultiColorEx(long x1, long y1, long x2, long y2, const wchar_t* first_color, const wchar_t* offset_color, double sim, long dir, std::wstring& retstr);
 	//查找指定区域内的图片
-	void FindPic(long x1,long y1,long x2,long y2,const wchar_t* files, const wchar_t* delta_color,double sim,long dir,long* x,long* y,long* ret);
+	void FindPic(long x1, long y1, long x2, long y2, const wchar_t* files, const wchar_t* delta_color, double sim, long dir, long* x, long* y, long* ret);
 	//查找多个图片
-	void FindPicEx(long x1, long y1, long x2, long y2, const wchar_t* files, const wchar_t* delta_color, double sim, long dir,std::wstring& retstr);
+	void FindPicEx(long x1, long y1, long x2, long y2, const wchar_t* files, const wchar_t* delta_color, double sim, long dir, std::wstring& retstr);
 	//
 	//这个函数可以查找多个图片, 并且返回所有找到的图像的坐标.此函数同FindPicEx.只是返回值不同.(file1,x,y|file2,x,y|...)
 	void FindPicExS(long x1, long y1, long x2, long y2, const wchar_t* files, const wchar_t* delta_color, double sim, long dir, std::wstring& retstr);
 	//查找指定区域内的颜色块,颜色格式"RRGGBB-DRDGDB",注意,和按键的颜色格式相反
-	void FindColorBlock(long x1, long y1, long x2, long y2, const wchar_t*  color, double sim, long count, long height, long width, long* x, long* y, long* ret);
+	void FindColorBlock(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, long count, long height, long width, long* x, long* y, long* ret);
 	//查找指定区域内的所有颜色块, 颜色格式"RRGGBB-DRDGDB", 注意, 和按键的颜色格式相反
-	void FindColorBlockEx(long x1, long y1, long x2, long y2, const wchar_t*  color, double sim, long count, long height, long width, std::wstring& retstr);
+	void FindColorBlockEx(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, long count, long height, long width, std::wstring& retstr);
 	//获取(x,y)的颜色
 	void GetColor(long x, long y, std::wstring& ret);
 	//
@@ -254,11 +251,11 @@ public:
 
 	void FreePic(const wchar_t* file_name, long* ret);
 	//从内存加载要查找的图片
-	void LoadMemPic(const wchar_t* file_name,void* data,long size, long* ret);
+	void LoadMemPic(const wchar_t* file_name, void* data, long size, long* ret);
 	//
-	void GetScreenData(long x1, long y1, long x2, long y2, void** data,long* ret);
+	void GetScreenData(long x1, long y1, long x2, long y2, void** data, long* ret);
 	//
-	void GetScreenDataBmp(long x1, long y1, long x2, long y2, void** data,long* size, long* ret);
+	void GetScreenDataBmp(long x1, long y1, long x2, long y2, void** data, long* size, long* ret);
 	//
 	void GetScreenFrameInfo(long* frame_id, long* time);
 	//
@@ -269,29 +266,28 @@ public:
 	//设置内存字库文件
 	void SetMemDict(long idx, const wchar_t* data, long size, long* ret);
 	//使用哪个字库文件进行识别
-	void UseDict(long idx,  long* ret);
+	void UseDict(long idx, long* ret);
 	//识别屏幕范围(x1,y1,x2,y2)内符合color_format的字符串,并且相似度为sim,sim取值范围(0.1-1.0),
-	void Ocr(long x1, long y1, long x2, long y2, const wchar_t* color, double sim,std::wstring& ret_str);
+	void Ocr(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, std::wstring& ret_str);
 	//回识别到的字符串,以及每个字符的坐标.
 	void OcrEx(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, std::wstring& ret_str);
 	//在屏幕范围(x1,y1,x2,y2)内,查找string(可以是任意个字符串的组合),并返回符合color_format的坐标位置
-	void FindStr(long x1, long y1, long x2, long y2,const wchar_t* strs, const wchar_t* color, double sim, long* retx,long* rety,long* ret);
+	void FindStr(long x1, long y1, long x2, long y2, const wchar_t* strs, const wchar_t* color, double sim, long* retx, long* rety, long* ret);
 	//返回符合color_format的所有坐标位置
-	void FindStrEx(long x1, long y1, long x2, long y2, const wchar_t* strs, const wchar_t* color, double sim,std::wstring& retstr);
+	void FindStrEx(long x1, long y1, long x2, long y2, const wchar_t* strs, const wchar_t* color, double sim, std::wstring& retstr);
 	//识别屏幕范围(x1,y1,x2,y2)内的字符串,自动二值化,而无需指定颜色
 	void OcrAuto(long x1, long y1, long x2, long y2, double sim, std::wstring& ret_str);
 	//从文件中识别图片
-	void OcrFromFile(const wchar_t* file_name,const wchar_t* color_format, double sim, std::wstring& retstr);
+	void OcrFromFile(const wchar_t* file_name, const wchar_t* color_format, double sim, std::wstring& retstr);
 	//从文件中识别图片,无需指定颜色
 	void OcrAutoFromFile(const wchar_t* file_name, double sim, std::wstring& retstr);
 	//查找频幕中的直线
 	void FindLine(long x1, long y1, long x2, long y2, const wchar_t* color, double sim, std::wstring& retstr);
-	
+
 	//向某进程写入数据
 	void WriteData(long hwnd, const wchar_t* address, const wchar_t* data, long size, long* ret);
 	//读取数据
 	void ReadData(long hwnd, const wchar_t* address, long size, std::wstring& retstr);
-		
 };
 
 

+ 3 - 7
gm/gm/winapi/Injecter.cpp

@@ -1,12 +1,10 @@
 //#include "stdafx.h"
 #include "Injecter.h"
 
-
 Injecter::Injecter()
 {
 }
 
-
 Injecter::~Injecter()
 {
 }
@@ -37,11 +35,9 @@ BOOL Injecter::EnablePrivilege(BOOL enable)
 	return TRUE;
 }
 
-
-long Injecter::InjectDll(DWORD pid, LPCTSTR dllPath,long& error_code)
+long Injecter::InjectDll(DWORD pid, LPCTSTR dllPath, long& error_code)
 {
-	
-	auto jhandle=::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
+	auto jhandle = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
 	/**pid = processInfo.dwProcessId;
 	*process = processInfo.hProcess;*/
 	if (!jhandle) {
@@ -68,7 +64,7 @@ long Injecter::InjectDll(DWORD pid, LPCTSTR dllPath,long& error_code)
 	}
 
 	// 创建远线程调用LoadLibrary
-	auto lpfn=GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "LoadLibraryW");
+	auto lpfn = GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "LoadLibraryW");
 	if (!lpfn) {
 		error_code = ::GetLastError();
 		return -4;

+ 3 - 3
gm/gm/winapi/Injecter.h

@@ -1,5 +1,6 @@
 #pragma once
 #include "core/optype.h"
+
 class Injecter
 {
 public:
@@ -7,6 +8,5 @@ public:
 	~Injecter();
 	static BOOL EnablePrivilege(BOOL enable);
 	// 
-	static long InjectDll(DWORD pid, LPCTSTR dllPath,long& error_code);
-};
-
+	static long InjectDll(DWORD pid, LPCTSTR dllPath, long& error_code);
+};

+ 43 - 26
gm/gm/winapi/MemoryEx.cpp

@@ -1,10 +1,12 @@
 //#include "stdafx.h"
 #include "MemoryEx.h"
 #include "./core/helpfunc.h"
+
 #define push(s,x)s.push_back(x)
 #define pop(s) s.back();s.pop_back()
 
-int get_op_prior(wchar_t op) {
+int get_op_prior(wchar_t op) 
+{
 	if (op == L'+' || op == L'-')
 		return 0;
 	if (op == L'*' || op == L'/')
@@ -12,11 +14,13 @@ int get_op_prior(wchar_t op) {
 	return 2;
 }
 
-bool is_op(wchar_t op) {
+bool is_op(wchar_t op) 
+{
 	return op == L'+' || op == L'-' || op == L'*' || op == L'/';
 }
 
-int do_op(int a, int b, wchar_t op) {
+int do_op(int a, int b, wchar_t op) 
+{
 	int ans;
 	if (op == L'+')
 		ans = a + b;
@@ -30,8 +34,10 @@ int do_op(int a, int b, wchar_t op) {
 		ans = 0;
 	return ans;
 }
+
 //like AA+BB+DD-CC*cc
-int stringcompute(const wchar_t* s) {
+int stringcompute(const wchar_t* s) 
+{
 	int ans = 0;
 	if (!s || !*s)
 		return 0;
@@ -88,42 +94,41 @@ MemoryEx::MemoryEx()
 {
 }
 
-
 MemoryEx::~MemoryEx()
 {
 }
 
-long MemoryEx::WriteData(HWND hwnd, const wstring& address, const wstring& data, LONG size) {
+long MemoryEx::WriteData(HWND hwnd, const wstring& address, const wstring& data, LONG size) 
+{
 	_hwnd = hwnd;
 	if (!checkaddress(address))
 		return 0;
 	vector<uchar> bin;
-	hex2bins(bin, data,size);
+	hex2bins(bin, data, size);
 	if (_hwnd) {
 		if (!::IsWindow(hwnd))
 			return 0;
 		DWORD pid;
 		::GetWindowThreadProcessId(hwnd, &pid);
 		auto hr = _proc.Attach(pid);
-		
+
 		if (hr >= 0) {
 			size_t addr = str2address(address);
 			if (addr == 0)return 0;
 			return mem_write(addr, bin.data(), size);
-			
+
 		}
 		return 0;
 	}
 	else {
 		size_t addr = str2address(address);
 		if (addr == 0)return 0;
-		return mem_write(addr,bin.data(), size);
+		return mem_write(addr, bin.data(), size);
 	}
-	
-
 }
 
-wstring MemoryEx::ReadData(HWND hwnd, const wstring& address, LONG size) {
+wstring MemoryEx::ReadData(HWND hwnd, const wstring& address, LONG size) 
+{
 	_hwnd = hwnd;
 	if (!checkaddress(address))
 		return L"";
@@ -140,7 +145,7 @@ wstring MemoryEx::ReadData(HWND hwnd, const wstring& address, LONG size) {
 		if (hr >= 0) {
 			size_t addr = str2address(address);
 			if (addr == 0)return L"";
-			 mem_read(bin.data(), addr, size);
+			mem_read(bin.data(), addr, size);
 		}
 	}
 	else {
@@ -150,22 +155,26 @@ wstring MemoryEx::ReadData(HWND hwnd, const wstring& address, LONG size) {
 	}
 
 	bin2hexs(bin, hex);
-	return hex;
 
+	return hex;
 }
 
-bool MemoryEx::mem_read(void* dst, size_t src, size_t size) {
-	if (_hwnd) {
+bool MemoryEx::mem_read(void* dst, size_t src, size_t size) 
+{
+	if (_hwnd) 
+	{
 		return _proc.memory().Read(src, size, dst) >= 0;
 	}
-	else {
+	else 
+	{
 		::memcpy(dst, (void*)src, size);
 		return true;
 	}
 
 }
 
-bool MemoryEx::mem_write(size_t dst, void* src, size_t size) {
+bool MemoryEx::mem_write(size_t dst, void* src, size_t size) 
+{
 	if (_hwnd) {
 		return _proc.memory().Write(dst, size, src) >= 0;
 	}
@@ -175,7 +184,8 @@ bool MemoryEx::mem_write(size_t dst, void* src, size_t size) {
 	}
 }
 
-bool MemoryEx::checkaddress(const wstring& address) {
+bool MemoryEx::checkaddress(const wstring& address) 
+{
 	vector<wchar_t> sk;
 	auto p = address.data();
 	while (*p) {
@@ -189,10 +199,12 @@ bool MemoryEx::checkaddress(const wstring& address) {
 		}
 		p++;
 	}
+
 	return sk.empty();
 }
 
-size_t MemoryEx::str2address(const wstring& caddress) {
+size_t MemoryEx::str2address(const wstring& caddress)
+{
 	wstring address = caddress;
 	if (!checkaddress(address))
 		return 0;
@@ -202,7 +214,8 @@ size_t MemoryEx::str2address(const wstring& caddress) {
 	size_t re = 0;
 	idx1 = address.find(L'<');
 	idx2 = address.find(L'>');
-	if (idx1 != -1 && idx2 != -1 && idx1 < idx2) {
+	if (idx1 != -1 && idx2 != -1 && idx1 < idx2) 
+	{
 		auto mod_name = address.substr(idx1 + 1, idx2 - idx1 - 1);
 		HMODULE hmod = NULL;
 		if (_hwnd == 0)
@@ -216,6 +229,7 @@ size_t MemoryEx::str2address(const wstring& caddress) {
 		wsprintf(buff, L"%X", hmod);
 		address.replace(idx1, idx2 - idx1 + 1, buff);
 	}
+
 	for (int i = 0; i < address.size();) {
 		if (address[i] == L'[')push(sk, i);
 		if (address[i] == L']') {
@@ -233,21 +247,24 @@ size_t MemoryEx::str2address(const wstring& caddress) {
 		}
 		++i;
 	}
+
 	return stringcompute(address.data());
 }
 
-void MemoryEx::hex2bins(vector<uchar>&bin, const wstring& hex,size_t size) {
+void MemoryEx::hex2bins(vector<uchar>& bin, const wstring& hex, size_t size)
+{
 	bin.resize(size);
 	ZeroMemory(bin.data(), bin.size());
 	int low = 1;
 	for (int i = hex.size() - 1; i >= 0; --i) {
-		
-		bin[size - i / 2-1] |= low & 1 ? hex2bin(hex[i]) : hex2bin(hex[i]) << 4;
+
+		bin[size - i / 2 - 1] |= low & 1 ? hex2bin(hex[i]) : hex2bin(hex[i]) << 4;
 		low ^= 1;
 	}
 }
 
-void MemoryEx::bin2hexs(const vector<uchar>&bin, wstring& hex) {
+void MemoryEx::bin2hexs(const vector<uchar>& bin, wstring& hex) 
+{
 	//hex.resize(bin.size() * 2);
 	hex.reserve(bin.size() * 2);
 	hex.clear();

+ 4 - 3
gm/gm/winapi/MemoryEx.h

@@ -1,8 +1,10 @@
 #pragma once
 #ifndef __MEMORYEX_H_
 #define __MEMORYEX_H_
+
 #include "./core/helpfunc.h"
 #include "BlackBone/Process/Process.h"
+
 class MemoryEx
 {
 public:
@@ -14,12 +16,11 @@ public:
 	size_t str2address(const wstring& caddress);
 	bool mem_read(void* dst, size_t src, size_t size);
 	bool mem_write(size_t dst, void* src, size_t size);
-	void hex2bins(vector<uchar>&bin, const wstring& hex,size_t size);
-	void bin2hexs(const vector<uchar>&bin, wstring& hex);
+	void hex2bins(vector<uchar>& bin, const wstring& hex, size_t size);
+	void bin2hexs(const vector<uchar>& bin, wstring& hex);
 private:
 	blackbone::Process _proc;
 	HWND _hwnd;
 };
 
-
 #endif

+ 2891 - 2792
gm/gm/winapi/WinApi.cpp

@@ -1,211 +1,236 @@
 //#include "stdafx.h"
 #include "WinApi.h"
-
 #include <Tlhelp32.h>
 #include <psapi.h>
-
 #include <memory>
 #pragma comment(lib, "psapi.lib")
 
 WinApi::WinApi(void) {
-  retstringlen = 0;
-  WindowVerion = 0;
-  IsEuemprosuccess = 0;
-  memset(npid, 0, MAX_PATH);
+	retstringlen = 0;
+	WindowVerion = 0;
+	IsEuemprosuccess = 0;
+	memset(npid, 0, MAX_PATH);
+}
+
+WinApi::~WinApi(void) 
+{
+
 }
 
-WinApi::~WinApi(void) {}
-
-BOOL WinApi::EnumProcessbyName(DWORD dwPID, LPCWSTR ExeName, LONG type) {
-  if (IsEuemprosuccess == 0) {
-    int nItem = 0;  // 项计数
-    PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};
-    HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-    if (hProcessSnap == INVALID_HANDLE_VALUE) return FALSE;
-    if (::Process32First(hProcessSnap, &pe32)) {
-      do {
-        if (type == 1) {
-          if (wcsstr(pe32.szExeFile, ExeName) != NULL)  //模糊匹配
-          {
-            npid[nItem] = pe32.th32ProcessID;
-            IsEuemprosuccess++;
-            nItem++;
-          }
-        } else {
-          if (!_wcsicmp(pe32.szExeFile, ExeName)) {
-            npid[nItem] = pe32.th32ProcessID;
-            IsEuemprosuccess++;
-            nItem++;
-          }
-        }
-
-      } while (::Process32Next(hProcessSnap, &pe32));
-    }
-    ::CloseHandle(hProcessSnap);
-    if (IsEuemprosuccess > 0) return TRUE;
-  } else {
-    for (int i = 0; i < IsEuemprosuccess; i++) {
-      if (dwPID == npid[i]) return TRUE;
-    }
-  }
-
-  return FALSE;
+BOOL WinApi::EnumProcessbyName(DWORD dwPID, LPCWSTR ExeName, LONG type) 
+{
+	if (IsEuemprosuccess == 0) 
+	{
+		int nItem = 0;  // 项计数
+		PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) };
+		HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+		if (hProcessSnap == INVALID_HANDLE_VALUE) return FALSE;
+		if (::Process32First(hProcessSnap, &pe32)) 
+		{
+			do {
+				if (type == 1) {
+					if (wcsstr(pe32.szExeFile, ExeName) != NULL)  //模糊匹配
+					{
+						npid[nItem] = pe32.th32ProcessID;
+						IsEuemprosuccess++;
+						nItem++;
+					}
+				}
+				else {
+					if (!_wcsicmp(pe32.szExeFile, ExeName)) {
+						npid[nItem] = pe32.th32ProcessID;
+						IsEuemprosuccess++;
+						nItem++;
+					}
+				}
+
+			} while (::Process32Next(hProcessSnap, &pe32));
+		}
+		::CloseHandle(hProcessSnap);
+
+		if (IsEuemprosuccess > 0) return TRUE;
+	}
+	else 
+	{
+		for (int i = 0; i < IsEuemprosuccess; i++) {
+			if (dwPID == npid[i]) return TRUE;
+		}
+	}
+
+	return FALSE;
 }
 
-DWORD WinApi::FindChildWnd(HWND hchile, const wchar_t *title,
-                           const wchar_t *classname, wchar_t *retstring,
-                           bool isGW_OWNER, bool isVisible,
-                           const wchar_t *process_name) {
-  hchile = ::GetWindow(hchile, GW_HWNDFIRST);
-  while (hchile != NULL) {
-    if (isGW_OWNER)  //判断是否要匹配所有者窗口为0的窗口,即顶级窗口
-      if (::GetWindow(hchile, GW_OWNER) != 0) {
-        hchile = ::GetWindow(hchile, GW_HWNDNEXT);  //获取下一个窗口
-        continue;
-      }
-
-    if (isVisible)  //判断是否匹配可视窗口
-      if (::IsWindowVisible(hchile) == false) {
-        hchile = ::GetWindow(hchile, GW_HWNDNEXT);  //获取下一个窗口
-        continue;
-      }
-    if (title == NULL && classname == NULL) {
-      if (process_name) {
-        DWORD pid = 0;
-        GetWindowThreadProcessId(hchile, &pid);
-        if (EnumProcessbyName(pid, process_name)) {
-          if (retstring) {
-            if (retstringlen == 0) retstringlen = wcslen(retstring);
-            if (retstringlen > 1)
-              swprintf(retstring, L"%s,%d", retstring, hchile);
-            else
-              swprintf(retstring, L"%d", hchile);
-          } else
-            return (DWORD)hchile;
-        }
-      } else {
-        if (retstring) {
-          int len = wcslen(retstring);
-          if (len > 1)
-            swprintf(retstring, L"%s,%d", retstring, hchile);
-          else
-            swprintf(retstring, L"%d", hchile);
-        } else
-          return (DWORD)hchile;
-      }
-    } else if (title != NULL && classname != NULL) {
-      wchar_t WindowClassName[MAX_PATH] = {0};
-      ::GetClassName(hchile, WindowClassName, MAX_PATH);
-      wchar_t WindowTitle[MAX_PATH] = {0};
-      ::GetWindowText(hchile, WindowTitle, MAX_PATH);
-      if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-        wchar_t *strfindclass = wcsstr(WindowClassName, classname);  //模糊匹配
-        wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-        if (strfindclass && strfindtitle) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(hchile, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (retstring) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, hchile);
-                else
-                  swprintf(retstring, L"%d", hchile);
-              } else
-                return (DWORD)hchile;
-            }
-          } else {
-            if (retstring) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, hchile);
-              else
-                swprintf(retstring, L"%d", hchile);
-            } else
-              return (DWORD)hchile;
-          }
-        }
-      }
-
-    } else if (title != NULL) {
-      wchar_t WindowTitle[MAX_PATH] = {0};
-      ::GetWindowText(hchile, WindowTitle, MAX_PATH);
-      if (wcslen(WindowTitle) > 1) {
-        wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-        if (strfind) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(hchile, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (retstring) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, hchile);
-                else
-                  swprintf(retstring, L"%d", hchile);
-              } else
-                return (DWORD)hchile;
-            }
-          } else {
-            if (retstring) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, hchile);
-              else
-                swprintf(retstring, L"%d", hchile);
-            } else
-              return (DWORD)hchile;
-          }
-        }
-      }
-
-    } else if (classname != NULL) {
-      wchar_t WindowClassName[MAX_PATH] = {0};
-      ::GetClassName(hchile, WindowClassName, MAX_PATH);
-      if (wcslen(WindowClassName) > 1) {
-        wchar_t *strfind = wcsstr(WindowClassName, classname);  //模糊匹配
-        if (strfind) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(hchile, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (retstring) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, hchile);
-                else
-                  swprintf(retstring, L"%d", hchile);
-              } else
-                return (DWORD)hchile;
-            }
-          } else {
-            if (retstring) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, hchile);
-              else
-                swprintf(retstring, L"%d", hchile);
-            } else
-              return (DWORD)hchile;
-          }
-        }
-      }
-    }
-
-    HWND hchilechile = ::GetWindow(hchile, GW_CHILD);
-    if (hchilechile != NULL) {
-      DWORD dret = FindChildWnd(hchilechile, title, classname, retstring,
-                                isGW_OWNER, isVisible, process_name);
-      if (dret > 0) break;
-    }
-
-    hchile = ::GetWindow(hchile, GW_HWNDNEXT);  //获取下一个窗口
-  }
-  return 0;
+DWORD WinApi::FindChildWnd(HWND hchile, const wchar_t* title,const wchar_t* classname, wchar_t* retstring,bool isGW_OWNER, bool isVisible,	const wchar_t* process_name) 
+{
+	hchile = ::GetWindow(hchile, GW_HWNDFIRST);
+	while (hchile != NULL)
+	{
+		if (isGW_OWNER)  //判断是否要匹配所有者窗口为0的窗口,即顶级窗口
+			if (::GetWindow(hchile, GW_OWNER) != 0) {
+				hchile = ::GetWindow(hchile, GW_HWNDNEXT);  //获取下一个窗口
+				continue;
+			}
+
+		if (isVisible)  //判断是否匹配可视窗口
+		{
+			if (::IsWindowVisible(hchile) == false) {
+				hchile = ::GetWindow(hchile, GW_HWNDNEXT);  //获取下一个窗口
+				continue;
+			}
+		}
+
+		if (title == NULL && classname == NULL) 
+		{
+			if (process_name) {
+				DWORD pid = 0;
+				GetWindowThreadProcessId(hchile, &pid);
+				if (EnumProcessbyName(pid, process_name)) {
+					if (retstring) {
+						if (retstringlen == 0) retstringlen = wcslen(retstring);
+						if (retstringlen > 1)
+							swprintf(retstring, L"%s,%d", retstring, hchile);
+						else
+							swprintf(retstring, L"%d", hchile);
+					}
+					else
+						return (DWORD)hchile;
+				}
+			}
+			else {
+				if (retstring) {
+					int len = wcslen(retstring);
+					if (len > 1)
+						swprintf(retstring, L"%s,%d", retstring, hchile);
+					else
+						swprintf(retstring, L"%d", hchile);
+				}
+				else
+					return (DWORD)hchile;
+			}
+		}
+		else if (title != NULL && classname != NULL) 
+		{
+			wchar_t WindowClassName[MAX_PATH] = { 0 };
+			::GetClassName(hchile, WindowClassName, MAX_PATH);
+			wchar_t WindowTitle[MAX_PATH] = { 0 };
+			::GetWindowText(hchile, WindowTitle, MAX_PATH);
+			if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+				wchar_t* strfindclass = wcsstr(WindowClassName, classname);  //模糊匹配
+				wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+				if (strfindclass && strfindtitle) {
+					if (process_name)  // EnumWindowByProcess
+					{
+						DWORD pid = 0;
+						GetWindowThreadProcessId(hchile, &pid);
+						if (EnumProcessbyName(pid, process_name)) {
+							if (retstring) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, hchile);
+								else
+									swprintf(retstring, L"%d", hchile);
+							}
+							else
+								return (DWORD)hchile;
+						}
+					}
+					else {
+						if (retstring) {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, hchile);
+							else
+								swprintf(retstring, L"%d", hchile);
+						}
+						else
+							return (DWORD)hchile;
+					}
+				}
+			}
+		}
+		else if (title != NULL) {
+			wchar_t WindowTitle[MAX_PATH] = { 0 };
+			::GetWindowText(hchile, WindowTitle, MAX_PATH);
+			if (wcslen(WindowTitle) > 1) {
+				wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+				if (strfind) {
+					if (process_name)  // EnumWindowByProcess
+					{
+						DWORD pid = 0;
+						GetWindowThreadProcessId(hchile, &pid);
+						if (EnumProcessbyName(pid, process_name)) {
+							if (retstring) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, hchile);
+								else
+									swprintf(retstring, L"%d", hchile);
+							}
+							else
+								return (DWORD)hchile;
+						}
+					}
+					else {
+						if (retstring) {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, hchile);
+							else
+								swprintf(retstring, L"%d", hchile);
+						}
+						else
+							return (DWORD)hchile;
+					}
+				}
+			}
+		}
+		else if (classname != NULL) {
+			wchar_t WindowClassName[MAX_PATH] = { 0 };
+			::GetClassName(hchile, WindowClassName, MAX_PATH);
+			if (wcslen(WindowClassName) > 1) {
+				wchar_t* strfind = wcsstr(WindowClassName, classname);  //模糊匹配
+				if (strfind) {
+					if (process_name)  // EnumWindowByProcess
+					{
+						DWORD pid = 0;
+						GetWindowThreadProcessId(hchile, &pid);
+						if (EnumProcessbyName(pid, process_name)) {
+							if (retstring) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, hchile);
+								else
+									swprintf(retstring, L"%d", hchile);
+							}
+							else
+								return (DWORD)hchile;
+						}
+					}
+					else {
+						if (retstring) {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, hchile);
+							else
+								swprintf(retstring, L"%d", hchile);
+						}
+						else
+							return (DWORD)hchile;
+					}
+				}
+			}
+		}
+
+		HWND hchilechile = ::GetWindow(hchile, GW_CHILD);
+		if (hchilechile != NULL) {
+			DWORD dret = FindChildWnd(hchilechile, title, classname, retstring,
+				isGW_OWNER, isVisible, process_name);
+			if (dret > 0) break;
+		}
+
+		hchile = ::GetWindow(hchile, GW_HWNDNEXT);  //获取下一个窗口
+	}
+	return 0;
 }
 
 // TSEnumWindow:filter整形数: 取值定义如下
@@ -221,2662 +246,2736 @@ DWORD WinApi::FindChildWnd(HWND hchile, const wchar_t *title,
 // 16 : 匹配可见的窗口
 //
 // 32 : 匹配出的窗口按照窗口打开顺序依次排列
-bool WinApi::EnumWindow(HWND parent, const wchar_t *title,
-                        const wchar_t *class_name, LONG filter,
-                        wchar_t *retstring, const wchar_t *process_name) {
-  bool bret = false;
-  bool bZwindow = false;  //匹配出的窗口按照窗口打开顺序依次排列
-  if (parent == 0) {
-    parent = GetDesktopWindow();
-  }
-  if (filter > 32) {
-    bZwindow = true;  //说明要排序窗口句柄
-    filter = filter - 32;
-  }
-
-  DWORD procpids[MAX_PATH] = {0};
-  int indexpid = 0;
-  if (process_name)  // EnumWindowByProcess
-  {
-    if (wcslen(process_name) < 1) return false;
-    memset(npid, 0, MAX_PATH);
-    IsEuemprosuccess = 0;
-    if (EnumProcessbyName(0, process_name) == false) return false;
-  }
-
-  DWORD processpid = 0;
-  retstringlen = 0;
-  switch (filter) {
-    case 0:  //所有模式
-    {
-      if (process_name)  // EnumWindowByProcess
-      {
-        return false;
-      }
-
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (retstringlen == 0) retstringlen = wcslen(retstring);
-        if (retstringlen > 1)
-          swprintf(retstring, L"%s,%d", retstring, p);
-        else
-          swprintf(retstring, L"%d", p);
-        bret = true;
-        HWND hchile = ::GetWindow(p, GW_CHILD);
-        if (hchile != NULL) {
-          FindChildWnd(hchile, NULL, NULL, retstring);
-        }
-
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 1:  // 1 : 匹配窗口标题,参数title有效
-    {
-      if (wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        wchar_t WindowTitle[MAX_PATH] = {0};
-        ::GetWindowText(p, WindowTitle, MAX_PATH);
-        if (wcslen(WindowTitle) > 1) {
-          wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-          if (strfind) {
-            if (process_name)  // EnumWindowByProcess
-            {
-              DWORD pid = 0;
-              GetWindowThreadProcessId(p, &pid);
-              if (EnumProcessbyName(pid, process_name)) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            } else {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, NULL, retstring);
-              }
-            }
-          }
-        }
-
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 2:  // 2 : 匹配窗口类名,参数class_name有效.
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        wchar_t WindowClassName[MAX_PATH] = {0};
-        ::GetClassName(p, WindowClassName, MAX_PATH);
-        if (wcslen(WindowClassName) > 1) {
-          wchar_t *strfind = wcsstr(WindowClassName, class_name);  //模糊匹配
-          if (strfind) {
-            if (process_name)  // EnumWindowByProcess
-            {
-              DWORD pid = 0;
-              GetWindowThreadProcessId(p, &pid);
-              if (EnumProcessbyName(pid, process_name)) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            } else {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, class_name, retstring);
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 3:  // 1.窗口标题+2.窗口类名
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        wchar_t WindowClassName[MAX_PATH] = {0};
-        ::GetClassName(p, WindowClassName, MAX_PATH);
-        wchar_t WindowTitle[MAX_PATH] = {0};
-        ::GetWindowText(p, WindowTitle, MAX_PATH);
-        if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-          wchar_t *strfindclass =
-              wcsstr(WindowClassName, class_name);             //模糊匹配
-          wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-          if (strfindclass && strfindtitle) {
-            if (process_name)  // EnumWindowByProcess
-            {
-              DWORD pid = 0;
-              GetWindowThreadProcessId(p, &pid);
-              if (EnumProcessbyName(pid, process_name)) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            } else {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, class_name, retstring);
-              }
-            }
-          }
-        }
-
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 4:  // 4 : 只匹配指定父窗口的第一层孩子窗口
-    {
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (process_name)  // EnumWindowByProcess
-        {
-          DWORD pid = 0;
-          GetWindowThreadProcessId(p, &pid);
-          if (EnumProcessbyName(pid, process_name)) {
-            if (processpid !=
-                pid)  //只匹配指定映像的所对应的第一个进程.
-                      //可能有很多同映像名的进程,只匹配第一个进程的.
-            {
-              if (indexpid < IsEuemprosuccess) {
-                indexpid++;
-                processpid = pid;
-                memset(retstring, 0, retstringlen);  //清空返回字符串
-                retstringlen = 0;
-              }
-            }
-            if (processpid == pid) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, NULL, retstring, false, false,
-                             process_name);
-              }
-            }
-          }
-        } else {
-          if (retstringlen == 0) retstringlen = wcslen(retstring);
-          if (retstringlen > 1)
-            swprintf(retstring, L"%s,%d", retstring, p);
-          else
-            swprintf(retstring, L"%d", p);
-          bret = true;
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 5:  // 1.匹配窗口标题+//4 : 只匹配指定父窗口的第一层孩子窗口
-    {
-      if (wcslen(title) < 1) return false;
-
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (process_name)  // EnumWindowByProcess
-        {
-          DWORD pid = 0;
-          GetWindowThreadProcessId(p, &pid);
-          if (EnumProcessbyName(pid, process_name)) {
-            if (processpid !=
-                pid)  //只匹配指定映像的所对应的第一个进程.
-                      //可能有很多同映像名的进程,只匹配第一个进程的.
-            {
-              if (indexpid < IsEuemprosuccess) {
-                indexpid++;
-                processpid = pid;
-                memset(retstring, 0, retstringlen);  //清空返回字符串
-                retstringlen = 0;
-              }
-            }
-            if (processpid == pid) {
-              wchar_t WindowTitle[MAX_PATH] = {0};
-              ::GetWindowText(p, WindowTitle, MAX_PATH);
-              if (wcslen(WindowTitle) > 1) {
-                if (wcsstr(WindowTitle, title)) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, NULL, retstring, false, false,
-                             process_name);
-              }
-            }
-          }
-
-        } else {
-          wchar_t WindowTitle[MAX_PATH] = {0};
-          ::GetWindowText(p, WindowTitle, MAX_PATH);
-          if (wcslen(WindowTitle) > 1) {
-            if (wcsstr(WindowTitle, title)) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-            }
-          }
-        }
-
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 6:  // 2 : 匹配窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (process_name)  // EnumWindowByProcess
-        {
-          DWORD pid = 0;
-          GetWindowThreadProcessId(p, &pid);
-          if (EnumProcessbyName(pid, process_name)) {
-            if (indexpid < IsEuemprosuccess) {
-              indexpid++;
-              processpid = pid;
-              memset(retstring, 0, retstringlen);  //清空返回字符串
-              retstringlen = 0;
-            }
-          }
-          if (processpid == pid) {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            if (wcslen(WindowClassName) > 1) {
-              if (wcsstr(WindowClassName, class_name)) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, NULL, class_name, retstring, false, false,
-                           process_name);
-            }
-          }
-        } else {
-          wchar_t WindowClassName[MAX_PATH] = {0};
-          ::GetClassName(p, WindowClassName, MAX_PATH);
-          if (wcslen(WindowClassName) > 1) {
-            if (wcsstr(WindowClassName, class_name)) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 7:  // 1.窗口标题+2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (process_name)  // EnumWindowByProcess
-        {
-          DWORD pid = 0;
-          GetWindowThreadProcessId(p, &pid);
-          if (EnumProcessbyName(pid, process_name)) {
-            if (indexpid < IsEuemprosuccess) {
-              indexpid++;
-              processpid = pid;
-              memset(retstring, 0, retstringlen);  //清空返回字符串
-              retstringlen = 0;
-            }
-          }
-          if (processpid == pid) {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfindclass && strfindtitle) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, title, class_name, retstring, false, false,
-                           process_name);
-            }
-          }
-        } else {
-          wchar_t WindowClassName[MAX_PATH] = {0};
-          ::GetClassName(p, WindowClassName, MAX_PATH);
-          wchar_t WindowTitle[MAX_PATH] = {0};
-          ::GetWindowText(p, WindowTitle, MAX_PATH);
-          if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-            wchar_t *strfindclass =
-                wcsstr(WindowClassName, class_name);             //模糊匹配
-            wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-            if (strfindclass && strfindtitle) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-            }
-          }
-        }
-
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 8:  // 8 : 匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, NULL, retstring, true, false,
-                             process_name);
-              }
-            }
-          } else {
-            if (retstringlen == 0) retstringlen = wcslen(retstring);
-            if (retstringlen > 1)
-              swprintf(retstring, L"%s,%d", retstring, p);
-            else
-              swprintf(retstring, L"%d", p);
-            bret = true;
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, NULL, NULL, retstring, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 9:  // 1.窗口标题+8 : 匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      if (wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowTitle[MAX_PATH] = {0};
-              ::GetWindowText(p, WindowTitle, MAX_PATH);
-              if (wcslen(WindowTitle) > 1) {
-                wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-                if (strfind) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, NULL, retstring, true, false,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowTitle) > 1) {
-              wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, title, NULL, retstring, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 10:  // 2.窗口类名+8 : 匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowClassName[MAX_PATH] = {0};
-              ::GetClassName(p, WindowClassName, MAX_PATH);
-              if (wcslen(WindowClassName) > 1) {
-                wchar_t *strfind =
-                    wcsstr(WindowClassName, class_name);  //模糊匹配
-                if (strfind) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, class_name, retstring, true, false,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            if (wcslen(WindowClassName) > 1) {
-              wchar_t *strfind =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, NULL, class_name, retstring, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 11:  ////1.窗口标题+2.窗口类名+8 : 匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      if (p == NULL) return false;
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowClassName[MAX_PATH] = {0};
-              ::GetClassName(p, WindowClassName, MAX_PATH);
-              wchar_t WindowTitle[MAX_PATH] = {0};
-              ::GetWindowText(p, WindowTitle, MAX_PATH);
-              if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-                wchar_t *strfindclass =
-                    wcsstr(WindowClassName, class_name);  //模糊匹配
-                wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-                if (strfindclass && strfindtitle) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, class_name, retstring, true, false,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfindclass && strfindtitle) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, title, class_name, retstring, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 12:  // //4 : 只匹配指定父窗口的第一层孩子窗口+8 :
-              // 匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, NULL, NULL, retstring, true, false,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            if (retstringlen == 0) retstringlen = wcslen(retstring);
-            if (retstringlen > 1)
-              swprintf(retstring, L"%s,%d", retstring, p);
-            else
-              swprintf(retstring, L"%d", p);
-            bret = true;
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 13:  // 1.窗口标题+4 : 只匹配指定父窗口的第一层孩子窗口+8 :
-              // 匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      if (wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowTitle[MAX_PATH] = {0};
-                ::GetWindowText(p, WindowTitle, MAX_PATH);
-                if (wcslen(WindowTitle) > 1) {
-                  wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-                  if (strfind) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, title, NULL, retstring, true, false,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowTitle) > 1) {
-              wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 14:  // 2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口+8 :
-              // 匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowClassName[MAX_PATH] = {0};
-                ::GetClassName(p, WindowClassName, MAX_PATH);
-                if (wcslen(WindowClassName) > 1) {
-                  wchar_t *strfind =
-                      wcsstr(WindowClassName, class_name);  //模糊匹配
-                  if (strfind) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, NULL, class_name, retstring, true, false,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            if (wcslen(WindowClassName) > 1) {
-              wchar_t *strfind =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 15:  ////1.窗口标题+2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口+8 :
-              ///匹配所有者窗口为0的窗口,即顶级窗口
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowClassName[MAX_PATH] = {0};
-                ::GetClassName(p, WindowClassName, MAX_PATH);
-                wchar_t WindowTitle[MAX_PATH] = {0};
-                ::GetWindowText(p, WindowTitle, MAX_PATH);
-                if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-                  wchar_t *strfindclass =
-                      wcsstr(WindowClassName, class_name);  //模糊匹配
-                  wchar_t *strfindtitle =
-                      wcsstr(WindowTitle, title);  //模糊匹配
-                  if (strfindclass && strfindtitle) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, title, class_name, retstring, true,
-                               false, process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfindclass && strfindtitle) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 16:  //匹配可见的窗口
-    {
-      parent = GetDesktopWindow();
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, NULL, retstring, false, true,
-                             process_name);
-              }
-            }
-          } else {
-            if (retstringlen == 0) retstringlen = wcslen(retstring);
-            if (retstringlen > 1)
-              swprintf(retstring, L"%s,%d", retstring, p);
-            else
-              swprintf(retstring, L"%d", p);
-            bret = true;
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, NULL, NULL, retstring, false, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 17:  // 1.窗口标题+//匹配可见的窗口
-    {
-      if (wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowTitle[MAX_PATH] = {0};
-              ::GetWindowText(p, WindowTitle, MAX_PATH);
-              if (wcslen(WindowTitle) > 1) {
-                wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-                if (strfind) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, NULL, retstring, false, true,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowTitle) > 1) {
-              wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, title, NULL, retstring, false, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 18:  // 2.窗口类名+//匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowClassName[MAX_PATH] = {0};
-              ::GetClassName(p, WindowClassName, MAX_PATH);
-              if (wcslen(WindowClassName) > 1) {
-                wchar_t *strfind =
-                    wcsstr(WindowClassName, class_name);  //模糊匹配
-                if (strfind) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, class_name, retstring, false, true,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            if (wcslen(WindowClassName) > 1) {
-              wchar_t *strfind =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, NULL, class_name, retstring, false, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 19:  ////1.窗口标题+2.窗口类名+匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowClassName[MAX_PATH] = {0};
-              ::GetClassName(p, WindowClassName, MAX_PATH);
-              wchar_t WindowTitle[MAX_PATH] = {0};
-              ::GetWindowText(p, WindowTitle, MAX_PATH);
-              if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-                wchar_t *strfindclass =
-                    wcsstr(WindowClassName, class_name);  //模糊匹配
-                wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-                if (strfindclass && strfindtitle) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, class_name, retstring, false, true,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfindclass && strfindtitle) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, title, class_name, retstring, false, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 20:  // 4 : 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
-    {
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, NULL, NULL, retstring, false, true,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            if (retstringlen == 0) retstringlen = wcslen(retstring);
-            if (retstringlen > 1)
-              swprintf(retstring, L"%s,%d", retstring, p);
-            else
-              swprintf(retstring, L"%d", p);
-            bret = true;
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 21:  // 1.窗口标题+4 : 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
-    {
-      if (wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowTitle[MAX_PATH] = {0};
-                ::GetWindowText(p, WindowTitle, MAX_PATH);
-                if (wcslen(WindowTitle) > 1) {
-                  wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-                  if (strfind) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, title, NULL, retstring, false, true,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowTitle) > 1) {
-              wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 22:  // 2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowClassName[MAX_PATH] = {0};
-                ::GetClassName(p, WindowClassName, MAX_PATH);
-                if (wcslen(WindowClassName) > 1) {
-                  wchar_t *strfind =
-                      wcsstr(WindowClassName, class_name);  //模糊匹配
-                  if (strfind) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, NULL, class_name, retstring, false, true,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            if (wcslen(WindowClassName) > 1) {
-              wchar_t *strfind =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 23:  // 1.窗口标题+2.窗口类名+4 :
-              // 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p)) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowClassName[MAX_PATH] = {0};
-                ::GetClassName(p, WindowClassName, MAX_PATH);
-                wchar_t WindowTitle[MAX_PATH] = {0};
-                ::GetWindowText(p, WindowTitle, MAX_PATH);
-                if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-                  wchar_t *strfindclass =
-                      wcsstr(WindowClassName, class_name);  //模糊匹配
-                  wchar_t *strfindtitle =
-                      wcsstr(WindowTitle, title);  //模糊匹配
-                  if (strfindclass && strfindtitle) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, title, class_name, retstring, false,
-                               true, process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfindclass && strfindtitle) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 24:  // 8 : 匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (retstringlen == 0) retstringlen = wcslen(retstring);
-              if (retstringlen > 1)
-                swprintf(retstring, L"%s,%d", retstring, p);
-              else
-                swprintf(retstring, L"%d", p);
-              bret = true;
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, NULL, retstring, true, true,
-                             process_name);
-              }
-            }
-          } else {
-            if (retstringlen == 0) retstringlen = wcslen(retstring);
-            if (retstringlen > 1)
-              swprintf(retstring, L"%s,%d", retstring, p);
-            else
-              swprintf(retstring, L"%d", p);
-            bret = true;
-
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, NULL, NULL, retstring, true, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 25:  // 1.窗口标题+
-              // 8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      if (wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowTitle[MAX_PATH] = {0};
-              ::GetWindowText(p, WindowTitle, MAX_PATH);
-              if (wcslen(WindowTitle) > 1) {
-                wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-                if (strfind) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, NULL, retstring, true, true,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowTitle) > 1) {
-              wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, title, NULL, retstring, true, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 26:  // 2.窗口类名+
-              // 8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowClassName[MAX_PATH] = {0};
-              ::GetClassName(p, WindowClassName, MAX_PATH);
-              if (wcslen(WindowClassName) > 1) {
-                wchar_t *strfind =
-                    wcsstr(WindowClassName, class_name);  //模糊匹配
-                if (strfind) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, NULL, class_name, retstring, true, true,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            if (wcslen(WindowClassName) > 1) {
-              wchar_t *strfind =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, NULL, class_name, retstring, true, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 27:  // 1.窗口标题+2.窗口类名+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              wchar_t WindowClassName[MAX_PATH] = {0};
-              ::GetClassName(p, WindowClassName, MAX_PATH);
-              wchar_t WindowTitle[MAX_PATH] = {0};
-              ::GetWindowText(p, WindowTitle, MAX_PATH);
-              if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-                wchar_t *strfindclass =
-                    wcsstr(WindowClassName, class_name);  //模糊匹配
-                wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-                if (strfindclass && strfindtitle) {
-                  if (retstringlen == 0) retstringlen = wcslen(retstring);
-                  if (retstringlen > 1)
-                    swprintf(retstring, L"%s,%d", retstring, p);
-                  else
-                    swprintf(retstring, L"%d", p);
-                  bret = true;
-                }
-              }
-              HWND hchile = ::GetWindow(p, GW_CHILD);
-              if (hchile != NULL) {
-                FindChildWnd(hchile, title, class_name, retstring, true, true,
-                             process_name);
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfindclass && strfindtitle) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              FindChildWnd(hchile, title, class_name, retstring, true, true);
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 28:  // 4 :
-              // 只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, NULL, NULL, retstring, true, true,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            if (retstringlen == 0) retstringlen = wcslen(retstring);
-            if (retstringlen > 1)
-              swprintf(retstring, L"%s,%d", retstring, p);
-            else
-              swprintf(retstring, L"%d", p);
-            bret = true;
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 29:  ////1.窗口标题+4 :
-              ///只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      if (wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowTitle[MAX_PATH] = {0};
-                ::GetWindowText(p, WindowTitle, MAX_PATH);
-                if (wcslen(WindowTitle) > 1) {
-                  wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-                  if (strfind) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, title, NULL, retstring, true, true,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowTitle) > 1) {
-              wchar_t *strfind = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 30:  // 2.窗口类名+4 :
-              // 只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowClassName[MAX_PATH] = {0};
-                ::GetClassName(p, WindowClassName, MAX_PATH);
-                if (wcslen(WindowClassName) > 1) {
-                  wchar_t *strfind =
-                      wcsstr(WindowClassName, class_name);  //模糊匹配
-                  if (strfind) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, NULL, class_name, retstring, true, true,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            if (wcslen(WindowClassName) > 1) {
-              wchar_t *strfind =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              if (strfind) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    case 31:  // 1.窗口标题+2.窗口类名+4 :
-              // 只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
-    {
-      if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
-      HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
-      p = ::GetWindow(p, GW_HWNDFIRST);
-      while (p != NULL) {
-        if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-          if (process_name)  // EnumWindowByProcess
-          {
-            DWORD pid = 0;
-            GetWindowThreadProcessId(p, &pid);
-            if (EnumProcessbyName(pid, process_name)) {
-              if (processpid !=
-                  pid)  //只匹配指定映像的所对应的第一个进程.
-                        //可能有很多同映像名的进程,只匹配第一个进程的.
-              {
-                if (indexpid < IsEuemprosuccess) {
-                  indexpid++;
-                  processpid = pid;
-                  memset(retstring, 0, retstringlen);  //清空返回字符串
-                  retstringlen = 0;
-                }
-              }
-              if (processpid == pid) {
-                wchar_t WindowClassName[MAX_PATH] = {0};
-                ::GetClassName(p, WindowClassName, MAX_PATH);
-                wchar_t WindowTitle[MAX_PATH] = {0};
-                ::GetWindowText(p, WindowTitle, MAX_PATH);
-                if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-                  wchar_t *strfindclass =
-                      wcsstr(WindowClassName, class_name);  //模糊匹配
-                  wchar_t *strfindtitle =
-                      wcsstr(WindowTitle, title);  //模糊匹配
-                  if (strfindclass && strfindtitle) {
-                    if (retstringlen == 0) retstringlen = wcslen(retstring);
-                    if (retstringlen > 1)
-                      swprintf(retstring, L"%s,%d", retstring, p);
-                    else
-                      swprintf(retstring, L"%d", p);
-                    bret = true;
-                  }
-                }
-                HWND hchile = ::GetWindow(p, GW_CHILD);
-                if (hchile != NULL) {
-                  FindChildWnd(hchile, title, class_name, retstring, true, true,
-                               process_name);
-                }
-              }
-            }
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if (strfindclass && strfindtitle) {
-                if (retstringlen == 0) retstringlen = wcslen(retstring);
-                if (retstringlen > 1)
-                  swprintf(retstring, L"%s,%d", retstring, p);
-                else
-                  swprintf(retstring, L"%d", p);
-                bret = true;
-              }
-            }
-          }
-        }
-        p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-      }
-      break;
-    }
-    default:
-      return bret;
-  }
-
-  return bret;
+bool WinApi::EnumWindow(HWND parent, const wchar_t* title,const wchar_t* class_name, LONG filter,wchar_t* retstring, const wchar_t* process_name) 
+{
+	bool bret = false;
+	bool bZwindow = false;  //匹配出的窗口按照窗口打开顺序依次排列
+	if (parent == 0) {
+		parent = GetDesktopWindow();
+	}
+	if (filter > 32) {
+		bZwindow = true;  //说明要排序窗口句柄
+		filter = filter - 32;
+	}
+
+	DWORD procpids[MAX_PATH] = { 0 };
+	int indexpid = 0;
+	if (process_name)  // EnumWindowByProcess
+	{
+		if (wcslen(process_name) < 1) return false;
+		memset(npid, 0, MAX_PATH);
+		IsEuemprosuccess = 0;
+		if (EnumProcessbyName(0, process_name) == false) return false;
+	}
+
+	DWORD processpid = 0;
+	retstringlen = 0;
+	switch (filter) {
+		case 0:  //所有模式
+			{
+				if (process_name)  // EnumWindowByProcess
+				{
+					return false;
+				}
+
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (retstringlen == 0) retstringlen = wcslen(retstring);
+					if (retstringlen > 1)
+						swprintf(retstring, L"%s,%d", retstring, p);
+					else
+						swprintf(retstring, L"%d", p);
+					bret = true;
+					HWND hchile = ::GetWindow(p, GW_CHILD);
+					if (hchile != NULL) {
+						FindChildWnd(hchile, NULL, NULL, retstring);
+					}
+
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 1:  // 1 : 匹配窗口标题,参数title有效
+			{
+				if (wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					wchar_t WindowTitle[MAX_PATH] = { 0 };
+					::GetWindowText(p, WindowTitle, MAX_PATH);
+					if (wcslen(WindowTitle) > 1) {
+						wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+						if (strfind) {
+							if (process_name)  // EnumWindowByProcess
+							{
+								DWORD pid = 0;
+								GetWindowThreadProcessId(p, &pid);
+								if (EnumProcessbyName(pid, process_name)) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							else {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, NULL, retstring);
+								}
+							}
+						}
+					}
+
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 2:  // 2 : 匹配窗口类名,参数class_name有效.
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					wchar_t WindowClassName[MAX_PATH] = { 0 };
+					::GetClassName(p, WindowClassName, MAX_PATH);
+					if (wcslen(WindowClassName) > 1) {
+						wchar_t* strfind = wcsstr(WindowClassName, class_name);  //模糊匹配
+						if (strfind) {
+							if (process_name)  // EnumWindowByProcess
+							{
+								DWORD pid = 0;
+								GetWindowThreadProcessId(p, &pid);
+								if (EnumProcessbyName(pid, process_name)) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							else {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, class_name, retstring);
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 3:  // 1.窗口标题+2.窗口类名
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					wchar_t WindowClassName[MAX_PATH] = { 0 };
+					::GetClassName(p, WindowClassName, MAX_PATH);
+					wchar_t WindowTitle[MAX_PATH] = { 0 };
+					::GetWindowText(p, WindowTitle, MAX_PATH);
+					if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+						wchar_t* strfindclass =
+							wcsstr(WindowClassName, class_name);             //模糊匹配
+						wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+						if (strfindclass && strfindtitle) {
+							if (process_name)  // EnumWindowByProcess
+							{
+								DWORD pid = 0;
+								GetWindowThreadProcessId(p, &pid);
+								if (EnumProcessbyName(pid, process_name)) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							else {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, class_name, retstring);
+								}
+							}
+						}
+					}
+
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 4:  // 4 : 只匹配指定父窗口的第一层孩子窗口
+			{
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (process_name)  // EnumWindowByProcess
+					{
+						DWORD pid = 0;
+						GetWindowThreadProcessId(p, &pid);
+						if (EnumProcessbyName(pid, process_name)) {
+							if (processpid !=
+								pid)  //只匹配指定映像的所对应的第一个进程.
+									  //可能有很多同映像名的进程,只匹配第一个进程的.
+							{
+								if (indexpid < IsEuemprosuccess) {
+									indexpid++;
+									processpid = pid;
+									memset(retstring, 0, retstringlen);  //清空返回字符串
+									retstringlen = 0;
+								}
+							}
+							if (processpid == pid) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, NULL, retstring, false, false,
+										process_name);
+								}
+							}
+						}
+					}
+					else {
+						if (retstringlen == 0) retstringlen = wcslen(retstring);
+						if (retstringlen > 1)
+							swprintf(retstring, L"%s,%d", retstring, p);
+						else
+							swprintf(retstring, L"%d", p);
+						bret = true;
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 5:  // 1.匹配窗口标题+//4 : 只匹配指定父窗口的第一层孩子窗口
+			{
+				if (wcslen(title) < 1) return false;
+
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (process_name)  // EnumWindowByProcess
+					{
+						DWORD pid = 0;
+						GetWindowThreadProcessId(p, &pid);
+						if (EnumProcessbyName(pid, process_name)) {
+							if (processpid !=
+								pid)  //只匹配指定映像的所对应的第一个进程.
+									  //可能有很多同映像名的进程,只匹配第一个进程的.
+							{
+								if (indexpid < IsEuemprosuccess) {
+									indexpid++;
+									processpid = pid;
+									memset(retstring, 0, retstringlen);  //清空返回字符串
+									retstringlen = 0;
+								}
+							}
+							if (processpid == pid) {
+								wchar_t WindowTitle[MAX_PATH] = { 0 };
+								::GetWindowText(p, WindowTitle, MAX_PATH);
+								if (wcslen(WindowTitle) > 1) {
+									if (wcsstr(WindowTitle, title)) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, NULL, retstring, false, false,
+										process_name);
+								}
+							}
+						}
+
+					}
+					else {
+						wchar_t WindowTitle[MAX_PATH] = { 0 };
+						::GetWindowText(p, WindowTitle, MAX_PATH);
+						if (wcslen(WindowTitle) > 1) {
+							if (wcsstr(WindowTitle, title)) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+							}
+						}
+					}
+
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 6:  // 2 : 匹配窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (process_name)  // EnumWindowByProcess
+					{
+						DWORD pid = 0;
+						GetWindowThreadProcessId(p, &pid);
+						if (EnumProcessbyName(pid, process_name)) {
+							if (indexpid < IsEuemprosuccess) {
+								indexpid++;
+								processpid = pid;
+								memset(retstring, 0, retstringlen);  //清空返回字符串
+								retstringlen = 0;
+							}
+						}
+						if (processpid == pid) {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							if (wcslen(WindowClassName) > 1) {
+								if (wcsstr(WindowClassName, class_name)) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, NULL, class_name, retstring, false, false,
+									process_name);
+							}
+						}
+					}
+					else {
+						wchar_t WindowClassName[MAX_PATH] = { 0 };
+						::GetClassName(p, WindowClassName, MAX_PATH);
+						if (wcslen(WindowClassName) > 1) {
+							if (wcsstr(WindowClassName, class_name)) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 7:  // 1.窗口标题+2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (process_name)  // EnumWindowByProcess
+					{
+						DWORD pid = 0;
+						GetWindowThreadProcessId(p, &pid);
+						if (EnumProcessbyName(pid, process_name)) {
+							if (indexpid < IsEuemprosuccess) {
+								indexpid++;
+								processpid = pid;
+								memset(retstring, 0, retstringlen);  //清空返回字符串
+								retstringlen = 0;
+							}
+						}
+						if (processpid == pid) {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+								wchar_t* strfindclass =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfindclass && strfindtitle) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, title, class_name, retstring, false, false,
+									process_name);
+							}
+						}
+					}
+					else {
+						wchar_t WindowClassName[MAX_PATH] = { 0 };
+						::GetClassName(p, WindowClassName, MAX_PATH);
+						wchar_t WindowTitle[MAX_PATH] = { 0 };
+						::GetWindowText(p, WindowTitle, MAX_PATH);
+						if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+							wchar_t* strfindclass =
+								wcsstr(WindowClassName, class_name);             //模糊匹配
+							wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+							if (strfindclass && strfindtitle) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+							}
+						}
+					}
+
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 8:  // 8 : 匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, NULL, retstring, true, false,
+										process_name);
+								}
+							}
+						}
+						else {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, p);
+							else
+								swprintf(retstring, L"%d", p);
+							bret = true;
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, NULL, NULL, retstring, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 9:  // 1.窗口标题+8 : 匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				if (wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowTitle[MAX_PATH] = { 0 };
+								::GetWindowText(p, WindowTitle, MAX_PATH);
+								if (wcslen(WindowTitle) > 1) {
+									wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+									if (strfind) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, NULL, retstring, true, false,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowTitle) > 1) {
+								wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, title, NULL, retstring, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 10:  // 2.窗口类名+8 : 匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowClassName[MAX_PATH] = { 0 };
+								::GetClassName(p, WindowClassName, MAX_PATH);
+								if (wcslen(WindowClassName) > 1) {
+									wchar_t* strfind =
+										wcsstr(WindowClassName, class_name);  //模糊匹配
+									if (strfind) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, class_name, retstring, true, false,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							if (wcslen(WindowClassName) > 1) {
+								wchar_t* strfind =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, NULL, class_name, retstring, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 11:  ////1.窗口标题+2.窗口类名+8 : 匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				if (p == NULL) return false;
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowClassName[MAX_PATH] = { 0 };
+								::GetClassName(p, WindowClassName, MAX_PATH);
+								wchar_t WindowTitle[MAX_PATH] = { 0 };
+								::GetWindowText(p, WindowTitle, MAX_PATH);
+								if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+									wchar_t* strfindclass =
+										wcsstr(WindowClassName, class_name);  //模糊匹配
+									wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+									if (strfindclass && strfindtitle) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, class_name, retstring, true, false,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+								wchar_t* strfindclass =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfindclass && strfindtitle) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, title, class_name, retstring, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 12:  // //4 : 只匹配指定父窗口的第一层孩子窗口+8 :
+				  // 匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, NULL, NULL, retstring, true, false,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, p);
+							else
+								swprintf(retstring, L"%d", p);
+							bret = true;
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 13:  // 1.窗口标题+4 : 只匹配指定父窗口的第一层孩子窗口+8 :
+				  // 匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				if (wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowTitle[MAX_PATH] = { 0 };
+									::GetWindowText(p, WindowTitle, MAX_PATH);
+									if (wcslen(WindowTitle) > 1) {
+										wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+										if (strfind) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, title, NULL, retstring, true, false,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowTitle) > 1) {
+								wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 14:  // 2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口+8 :
+				  // 匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowClassName[MAX_PATH] = { 0 };
+									::GetClassName(p, WindowClassName, MAX_PATH);
+									if (wcslen(WindowClassName) > 1) {
+										wchar_t* strfind =
+											wcsstr(WindowClassName, class_name);  //模糊匹配
+										if (strfind) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, NULL, class_name, retstring, true, false,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							if (wcslen(WindowClassName) > 1) {
+								wchar_t* strfind =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 15:  ////1.窗口标题+2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口+8 :
+				  ///匹配所有者窗口为0的窗口,即顶级窗口
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowClassName[MAX_PATH] = { 0 };
+									::GetClassName(p, WindowClassName, MAX_PATH);
+									wchar_t WindowTitle[MAX_PATH] = { 0 };
+									::GetWindowText(p, WindowTitle, MAX_PATH);
+									if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+										wchar_t* strfindclass =
+											wcsstr(WindowClassName, class_name);  //模糊匹配
+										wchar_t* strfindtitle =
+											wcsstr(WindowTitle, title);  //模糊匹配
+										if (strfindclass && strfindtitle) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, title, class_name, retstring, true,
+											false, process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+								wchar_t* strfindclass =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfindclass && strfindtitle) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 16:  //匹配可见的窗口
+			{
+				parent = GetDesktopWindow();
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, NULL, retstring, false, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, p);
+							else
+								swprintf(retstring, L"%d", p);
+							bret = true;
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, NULL, NULL, retstring, false, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 17:  // 1.窗口标题+//匹配可见的窗口
+			{
+				if (wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowTitle[MAX_PATH] = { 0 };
+								::GetWindowText(p, WindowTitle, MAX_PATH);
+								if (wcslen(WindowTitle) > 1) {
+									wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+									if (strfind) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, NULL, retstring, false, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowTitle) > 1) {
+								wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, title, NULL, retstring, false, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 18:  // 2.窗口类名+//匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowClassName[MAX_PATH] = { 0 };
+								::GetClassName(p, WindowClassName, MAX_PATH);
+								if (wcslen(WindowClassName) > 1) {
+									wchar_t* strfind =
+										wcsstr(WindowClassName, class_name);  //模糊匹配
+									if (strfind) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, class_name, retstring, false, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							if (wcslen(WindowClassName) > 1) {
+								wchar_t* strfind =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, NULL, class_name, retstring, false, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 19:  ////1.窗口标题+2.窗口类名+匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowClassName[MAX_PATH] = { 0 };
+								::GetClassName(p, WindowClassName, MAX_PATH);
+								wchar_t WindowTitle[MAX_PATH] = { 0 };
+								::GetWindowText(p, WindowTitle, MAX_PATH);
+								if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+									wchar_t* strfindclass =
+										wcsstr(WindowClassName, class_name);  //模糊匹配
+									wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+									if (strfindclass && strfindtitle) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, class_name, retstring, false, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+								wchar_t* strfindclass =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfindclass && strfindtitle) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, title, class_name, retstring, false, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 20:  // 4 : 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
+			{
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, NULL, NULL, retstring, false, true,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, p);
+							else
+								swprintf(retstring, L"%d", p);
+							bret = true;
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 21:  // 1.窗口标题+4 : 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
+			{
+				if (wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowTitle[MAX_PATH] = { 0 };
+									::GetWindowText(p, WindowTitle, MAX_PATH);
+									if (wcslen(WindowTitle) > 1) {
+										wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+										if (strfind) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, title, NULL, retstring, false, true,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowTitle) > 1) {
+								wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 22:  // 2.窗口类名+4 : 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowClassName[MAX_PATH] = { 0 };
+									::GetClassName(p, WindowClassName, MAX_PATH);
+									if (wcslen(WindowClassName) > 1) {
+										wchar_t* strfind =
+											wcsstr(WindowClassName, class_name);  //模糊匹配
+										if (strfind) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, NULL, class_name, retstring, false, true,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							if (wcslen(WindowClassName) > 1) {
+								wchar_t* strfind =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 23:  // 1.窗口标题+2.窗口类名+4 :
+				  // 只匹配指定父窗口的第一层孩子窗口+匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p)) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowClassName[MAX_PATH] = { 0 };
+									::GetClassName(p, WindowClassName, MAX_PATH);
+									wchar_t WindowTitle[MAX_PATH] = { 0 };
+									::GetWindowText(p, WindowTitle, MAX_PATH);
+									if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+										wchar_t* strfindclass =
+											wcsstr(WindowClassName, class_name);  //模糊匹配
+										wchar_t* strfindtitle =
+											wcsstr(WindowTitle, title);  //模糊匹配
+										if (strfindclass && strfindtitle) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, title, class_name, retstring, false,
+											true, process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+								wchar_t* strfindclass =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfindclass && strfindtitle) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 24:  // 8 : 匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (retstringlen == 0) retstringlen = wcslen(retstring);
+								if (retstringlen > 1)
+									swprintf(retstring, L"%s,%d", retstring, p);
+								else
+									swprintf(retstring, L"%d", p);
+								bret = true;
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, NULL, retstring, true, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, p);
+							else
+								swprintf(retstring, L"%d", p);
+							bret = true;
+
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, NULL, NULL, retstring, true, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 25:  // 1.窗口标题+
+				  // 8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				if (wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowTitle[MAX_PATH] = { 0 };
+								::GetWindowText(p, WindowTitle, MAX_PATH);
+								if (wcslen(WindowTitle) > 1) {
+									wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+									if (strfind) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, NULL, retstring, true, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowTitle) > 1) {
+								wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, title, NULL, retstring, true, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 26:  // 2.窗口类名+
+				  // 8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowClassName[MAX_PATH] = { 0 };
+								::GetClassName(p, WindowClassName, MAX_PATH);
+								if (wcslen(WindowClassName) > 1) {
+									wchar_t* strfind =
+										wcsstr(WindowClassName, class_name);  //模糊匹配
+									if (strfind) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, NULL, class_name, retstring, true, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							if (wcslen(WindowClassName) > 1) {
+								wchar_t* strfind =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, NULL, class_name, retstring, true, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 27:  // 1.窗口标题+2.窗口类名+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								wchar_t WindowClassName[MAX_PATH] = { 0 };
+								::GetClassName(p, WindowClassName, MAX_PATH);
+								wchar_t WindowTitle[MAX_PATH] = { 0 };
+								::GetWindowText(p, WindowTitle, MAX_PATH);
+								if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+									wchar_t* strfindclass =
+										wcsstr(WindowClassName, class_name);  //模糊匹配
+									wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+									if (strfindclass && strfindtitle) {
+										if (retstringlen == 0) retstringlen = wcslen(retstring);
+										if (retstringlen > 1)
+											swprintf(retstring, L"%s,%d", retstring, p);
+										else
+											swprintf(retstring, L"%d", p);
+										bret = true;
+									}
+								}
+								HWND hchile = ::GetWindow(p, GW_CHILD);
+								if (hchile != NULL) {
+									FindChildWnd(hchile, title, class_name, retstring, true, true,
+										process_name);
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+								wchar_t* strfindclass =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfindclass && strfindtitle) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+							HWND hchile = ::GetWindow(p, GW_CHILD);
+							if (hchile != NULL) {
+								FindChildWnd(hchile, title, class_name, retstring, true, true);
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 28:  // 4 :
+				  // 只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, NULL, NULL, retstring, true, true,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							if (retstringlen == 0) retstringlen = wcslen(retstring);
+							if (retstringlen > 1)
+								swprintf(retstring, L"%s,%d", retstring, p);
+							else
+								swprintf(retstring, L"%d", p);
+							bret = true;
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 29:  ////1.窗口标题+4 :
+				  ///只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				if (wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowTitle[MAX_PATH] = { 0 };
+									::GetWindowText(p, WindowTitle, MAX_PATH);
+									if (wcslen(WindowTitle) > 1) {
+										wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+										if (strfind) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, title, NULL, retstring, true, true,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowTitle) > 1) {
+								wchar_t* strfind = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 30:  // 2.窗口类名+4 :
+				  // 只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowClassName[MAX_PATH] = { 0 };
+									::GetClassName(p, WindowClassName, MAX_PATH);
+									if (wcslen(WindowClassName) > 1) {
+										wchar_t* strfind =
+											wcsstr(WindowClassName, class_name);  //模糊匹配
+										if (strfind) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, NULL, class_name, retstring, true, true,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							if (wcslen(WindowClassName) > 1) {
+								wchar_t* strfind =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								if (strfind) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		case 31:  // 1.窗口标题+2.窗口类名+4 :
+				  // 只匹配指定父窗口的第一层孩子窗口+8:匹配所有者窗口为0的窗口,即顶级窗口+16.匹配可见的窗口
+			{
+				if (wcslen(class_name) < 1 && wcslen(title) < 1) return false;
+				HWND p = ::GetWindow(parent, GW_CHILD);  //获取桌面窗口的子窗口
+				p = ::GetWindow(p, GW_HWNDFIRST);
+				while (p != NULL) {
+					if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+						if (process_name)  // EnumWindowByProcess
+						{
+							DWORD pid = 0;
+							GetWindowThreadProcessId(p, &pid);
+							if (EnumProcessbyName(pid, process_name)) {
+								if (processpid !=
+									pid)  //只匹配指定映像的所对应的第一个进程.
+										  //可能有很多同映像名的进程,只匹配第一个进程的.
+								{
+									if (indexpid < IsEuemprosuccess) {
+										indexpid++;
+										processpid = pid;
+										memset(retstring, 0, retstringlen);  //清空返回字符串
+										retstringlen = 0;
+									}
+								}
+								if (processpid == pid) {
+									wchar_t WindowClassName[MAX_PATH] = { 0 };
+									::GetClassName(p, WindowClassName, MAX_PATH);
+									wchar_t WindowTitle[MAX_PATH] = { 0 };
+									::GetWindowText(p, WindowTitle, MAX_PATH);
+									if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+										wchar_t* strfindclass =
+											wcsstr(WindowClassName, class_name);  //模糊匹配
+										wchar_t* strfindtitle =
+											wcsstr(WindowTitle, title);  //模糊匹配
+										if (strfindclass && strfindtitle) {
+											if (retstringlen == 0) retstringlen = wcslen(retstring);
+											if (retstringlen > 1)
+												swprintf(retstring, L"%s,%d", retstring, p);
+											else
+												swprintf(retstring, L"%d", p);
+											bret = true;
+										}
+									}
+									HWND hchile = ::GetWindow(p, GW_CHILD);
+									if (hchile != NULL) {
+										FindChildWnd(hchile, title, class_name, retstring, true, true,
+											process_name);
+									}
+								}
+							}
+						}
+						else {
+							wchar_t WindowClassName[MAX_PATH] = { 0 };
+							::GetClassName(p, WindowClassName, MAX_PATH);
+							wchar_t WindowTitle[MAX_PATH] = { 0 };
+							::GetWindowText(p, WindowTitle, MAX_PATH);
+							if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+								wchar_t* strfindclass =
+									wcsstr(WindowClassName, class_name);  //模糊匹配
+								wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+								if (strfindclass && strfindtitle) {
+									if (retstringlen == 0) retstringlen = wcslen(retstring);
+									if (retstringlen > 1)
+										swprintf(retstring, L"%s,%d", retstring, p);
+									else
+										swprintf(retstring, L"%d", p);
+									bret = true;
+								}
+							}
+						}
+					}
+					p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+				}
+				break;
+			}
+		default:
+			return bret;
+	}
+
+	return bret;
 }
 
-bool WinApi::EnumWindowSuper(wchar_t *spec1, LONG flag1, LONG type1,
-                             wchar_t *spec2, LONG flag2, LONG type2, LONG sort,
-                             wchar_t *retstring) {
-  bool bret = false;
-  wchar_t findhwnd1[MAX_PATH * 100] = {0};
-  wchar_t findhwnd2[MAX_PATH * 100] = {0};
-  bool bfindhwnd1 = false;
-  bool bfindhwnd2 = false;
-  retstringlen = 0;
-  HWND parent = GetDesktopWindow();
-  HWND p = ::GetWindow(parent, GW_CHILD);
-  p = ::GetWindow(p, GW_HWNDFIRST);
-  while (p != NULL) {
-    if (flag1 == 0)  // 0表示spec1的内容是标题
-    {
-      wchar_t WindowTitle[MAX_PATH] = {0};
-      ::GetWindowText(p, WindowTitle, MAX_PATH);
-      if (wcslen(WindowTitle) > 0) {
-        if (type1 == 0)  // 0精确判断,1模糊判断
-        {
-          if (wcscmp(spec1, WindowTitle) == 0) bfindhwnd1 = true;
-        } else if (type1 == 1) {
-          if (wcsstr(WindowTitle, spec1) != NULL) bfindhwnd1 = true;
-        }
-      }
-    } else if (flag1 == 1)  // 1表示spec1的内容是程序名字
-    {
-      DWORD pid = 0;
-      ::GetWindowThreadProcessId(p, &pid);
-      wchar_t proname[MAX_PATH] = {0};
-      GetProcesspath(pid, proname);
-    } else if (flag1 == 2)  // 2表示spec1的内容是类名
-    {
-      wchar_t WindowClassName[MAX_PATH] = {0};
-      ::GetClassName(p, WindowClassName, MAX_PATH);
-      if (wcslen(WindowClassName) > 0) {
-        if (type1 == 0)  // 0精确判断,1模糊判断
-        {
-          if (wcscmp(spec1, WindowClassName) == 0) bfindhwnd1 = true;
-        } else {
-          if (wcsstr(WindowClassName, spec1) != NULL) bfindhwnd1 = true;
-        }
-      }
-    }
-    if (bfindhwnd1) {
-      if (retstringlen == 0) retstringlen = wcslen(retstring);
-      if (retstringlen > 1)
-        swprintf(retstring, L"%s,%d", retstring, p);
-      else
-        swprintf(retstring, L"%d", p);
-      bfindhwnd1 = false;
-    }
-
-    HWND hchile = ::GetWindow(p, GW_CHILD);
-    if (hchile != NULL) {
-      FindChildWnd(hchile, NULL, NULL, findhwnd1);
-    }
-    p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-  }
-
-  return bret;
+bool WinApi::EnumWindowSuper(wchar_t* spec1, LONG flag1, LONG type1,wchar_t* spec2, LONG flag2, LONG type2, LONG sort,wchar_t* retstring) 
+{
+	bool bret = false;
+	wchar_t findhwnd1[MAX_PATH * 100] = { 0 };
+	wchar_t findhwnd2[MAX_PATH * 100] = { 0 };
+	bool bfindhwnd1 = false;
+	bool bfindhwnd2 = false;
+	retstringlen = 0;
+	HWND parent = GetDesktopWindow();
+	HWND p = ::GetWindow(parent, GW_CHILD);
+	p = ::GetWindow(p, GW_HWNDFIRST);
+	while (p != NULL) {
+		if (flag1 == 0)  // 0表示spec1的内容是标题
+		{
+			wchar_t WindowTitle[MAX_PATH] = { 0 };
+			::GetWindowText(p, WindowTitle, MAX_PATH);
+			if (wcslen(WindowTitle) > 0) {
+				if (type1 == 0)  // 0精确判断,1模糊判断
+				{
+					if (wcscmp(spec1, WindowTitle) == 0) bfindhwnd1 = true;
+				}
+				else if (type1 == 1) {
+					if (wcsstr(WindowTitle, spec1) != NULL) bfindhwnd1 = true;
+				}
+			}
+		}
+		else if (flag1 == 1)  // 1表示spec1的内容是程序名字
+		{
+			DWORD pid = 0;
+			::GetWindowThreadProcessId(p, &pid);
+			wchar_t proname[MAX_PATH] = { 0 };
+			GetProcesspath(pid, proname);
+		}
+		else if (flag1 == 2)  // 2表示spec1的内容是类名
+		{
+			wchar_t WindowClassName[MAX_PATH] = { 0 };
+			::GetClassName(p, WindowClassName, MAX_PATH);
+			if (wcslen(WindowClassName) > 0) {
+				if (type1 == 0)  // 0精确判断,1模糊判断
+				{
+					if (wcscmp(spec1, WindowClassName) == 0) bfindhwnd1 = true;
+				}
+				else {
+					if (wcsstr(WindowClassName, spec1) != NULL) bfindhwnd1 = true;
+				}
+			}
+		}
+		if (bfindhwnd1) {
+			if (retstringlen == 0) retstringlen = wcslen(retstring);
+			if (retstringlen > 1)
+				swprintf(retstring, L"%s,%d", retstring, p);
+			else
+				swprintf(retstring, L"%d", p);
+			bfindhwnd1 = false;
+		}
+
+		HWND hchile = ::GetWindow(p, GW_CHILD);
+		if (hchile != NULL) {
+			FindChildWnd(hchile, NULL, NULL, findhwnd1);
+		}
+		p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+	}
+
+	return bret;
 }
 
-bool WinApi::EnumProcess(const wchar_t *name, wchar_t *retstring) {
-  bool bret = false;
-  retstringlen = 0;
-  if (wcslen(name) < 1) return false;
-  IsEuemprosuccess = 0;
-  if (EnumProcessbyName(0, name) == true) {
-    bret = true;
-    for (int i = 0; i < IsEuemprosuccess; i++) {
-      if (retstringlen == 0) retstringlen = wcslen(retstring);
-      if (retstringlen > 1)
-        swprintf(retstring, L"%s,%d", retstring, npid[i]);
-      else
-        swprintf(retstring, L"%d", npid[i]);
-    }
-  }
-  return bret;
+bool WinApi::EnumProcess(const wchar_t* name, wchar_t* retstring) 
+{
+	bool bret = false;
+	retstringlen = 0;
+	if (wcslen(name) < 1) return false;
+	IsEuemprosuccess = 0;
+	if (EnumProcessbyName(0, name) == true) {
+		bret = true;
+		for (int i = 0; i < IsEuemprosuccess; i++) {
+			if (retstringlen == 0) retstringlen = wcslen(retstring);
+			if (retstringlen > 1)
+				swprintf(retstring, L"%s,%d", retstring, npid[i]);
+			else
+				swprintf(retstring, L"%d", npid[i]);
+		}
+	}
+	return bret;
 }
-bool WinApi::ClientToScreen(LONG hwnd, LONG &x, LONG &y) {
-  POINT point;
 
-  ::ClientToScreen((HWND)hwnd, &point);
+bool WinApi::ClientToScreen(LONG hwnd, LONG& x, LONG& y)
+{
+	POINT point;
+	::ClientToScreen((HWND)hwnd, &point);
 
-  x = point.x;
-  y = point.y;
+	x = point.x;
+	y = point.y;
 
-  return true;
+	return true;
 }
-long WinApi::FindWindow(const wchar_t *class_name, const wchar_t *title) {
-  if (class_name[0] == L'\0') class_name = nullptr;
-  if (title[0] == L'\0') title = nullptr;
-  return (LONG)::FindWindowW(class_name, title);
+
+long WinApi::FindWindow(const wchar_t* class_name, const wchar_t* title) 
+{
+	if (class_name[0] == L'\0') class_name = nullptr;
+	if (title[0] == L'\0') title = nullptr;
+	return (LONG)::FindWindowW(class_name, title);
 }
 
-long WinApi::FindWindowEx(long parent, const wchar_t *class_name,
-                          const wchar_t *title) {
-  if (class_name[0] == L'\0') class_name = nullptr;
-  if (title[0] == L'\0') title = nullptr;
-  return (long)::FindWindowExW((HWND)parent, NULL, class_name, title);
+long WinApi::FindWindowEx(long parent, const wchar_t* class_name,const wchar_t* title) 
+{
+	if (class_name[0] == L'\0') class_name = nullptr;
+	if (title[0] == L'\0') title = nullptr;
+	return (long)::FindWindowExW((HWND)parent, NULL, class_name, title);
 }
 
-bool WinApi::FindWindowByProcess(const wchar_t *class_name,
-                                 const wchar_t *title, LONG &rethwnd,
-                                 const wchar_t *process_name, DWORD Pid) {
-  bool bret = false;
-  rethwnd = 0;
-  if (process_name) {
-    if (wcslen(process_name) < 1) return false;
-    memset(npid, 0, MAX_PATH);
-    IsEuemprosuccess = 0;
-    if (EnumProcessbyName(0, process_name) == false) return false;
-
-    HWND p = ::GetWindow(GetDesktopWindow(), GW_CHILD);  //获取桌面窗口的子窗口
-    p = ::GetWindow(p, GW_HWNDFIRST);
-    while (p != NULL) {
-      if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-        DWORD pid = 0;
-        GetWindowThreadProcessId(p, &pid);
-        if (EnumProcessbyName(pid, process_name)) {
-          if (wcslen(class_name) < 1 && wcslen(title) < 1) {
-            rethwnd = (LONG)p;
-            bret = true;
-            break;
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if ((wcslen(class_name) >= 1 && strfindclass) ||
-                  (wcslen(title) >= 1 && strfindtitle)) {
-                rethwnd = (LONG)p;
-                bret = true;
-                break;
-              }
-            }
-
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              const wchar_t *classname = NULL;
-              const wchar_t *titles = NULL;
-              if (wcslen(class_name) > 0) classname = class_name;
-              if (wcslen(title) > 0) titles = titles;
-              DWORD dret = FindChildWnd(hchile, titles, classname, NULL, false,
-                                        false, process_name);
-              if (dret > 0) {
-                rethwnd = (LONG)dret;
-                bret = true;
-                break;
-              }
-            }
-          }
-        }
-      }
-      p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-    }
-  } else if (Pid > 0) {
-    HWND p = ::GetWindow(GetDesktopWindow(), GW_CHILD);  //获取桌面窗口的子窗口
-    p = ::GetWindow(p, GW_HWNDFIRST);
-    while (p != NULL) {
-      if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-        DWORD npid = 0;
-        GetWindowThreadProcessId(p, &npid);
-        if (Pid == npid) {
-          if (wcslen(class_name) < 1 && wcslen(title) < 1) {
-            rethwnd = (LONG)p;
-            bret = true;
-            break;
-          } else {
-            wchar_t WindowClassName[MAX_PATH] = {0};
-            ::GetClassName(p, WindowClassName, MAX_PATH);
-            wchar_t WindowTitle[MAX_PATH] = {0};
-            ::GetWindowText(p, WindowTitle, MAX_PATH);
-            if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
-              wchar_t *strfindclass =
-                  wcsstr(WindowClassName, class_name);  //模糊匹配
-              wchar_t *strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
-              if ((wcslen(class_name) >= 1 && strfindclass) ||
-                  (wcslen(title) >= 1 && strfindtitle)) {
-                rethwnd = (LONG)p;
-                bret = true;
-                break;
-              }
-            }
-            HWND hchile = ::GetWindow(p, GW_CHILD);
-            if (hchile != NULL) {
-              const wchar_t *classname = NULL;
-              const wchar_t *titles = NULL;
-              if (wcslen(class_name) > 0) classname = class_name;
-              if (wcslen(title) > 0) titles = titles;
-              DWORD dret = FindChildWnd(hchile, titles, classname, NULL, false,
-                                        false, process_name);
-              if (dret > 0) {
-                rethwnd = (LONG)dret;
-                bret = true;
-                break;
-              }
-            }
-          }
-        }
-      }
-      p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-    }
-  }
-
-  return bret;
+bool WinApi::FindWindowByProcess(const wchar_t* class_name,	const wchar_t* title, LONG& rethwnd, const wchar_t* process_name, DWORD Pid) 
+{
+	bool bret = false;
+	rethwnd = 0;
+	if (process_name) {
+		if (wcslen(process_name) < 1) return false;
+		memset(npid, 0, MAX_PATH);
+		IsEuemprosuccess = 0;
+		if (EnumProcessbyName(0, process_name) == false) return false;
+
+		HWND p = ::GetWindow(GetDesktopWindow(), GW_CHILD);  //获取桌面窗口的子窗口
+		p = ::GetWindow(p, GW_HWNDFIRST);
+		while (p != NULL) {
+			if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+				DWORD pid = 0;
+				GetWindowThreadProcessId(p, &pid);
+				if (EnumProcessbyName(pid, process_name)) {
+					if (wcslen(class_name) < 1 && wcslen(title) < 1) {
+						rethwnd = (LONG)p;
+						bret = true;
+						break;
+					}
+					else {
+						wchar_t WindowClassName[MAX_PATH] = { 0 };
+						::GetClassName(p, WindowClassName, MAX_PATH);
+						wchar_t WindowTitle[MAX_PATH] = { 0 };
+						::GetWindowText(p, WindowTitle, MAX_PATH);
+						if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+							wchar_t* strfindclass =
+								wcsstr(WindowClassName, class_name);  //模糊匹配
+							wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+							if ((wcslen(class_name) >= 1 && strfindclass) ||
+								(wcslen(title) >= 1 && strfindtitle)) {
+								rethwnd = (LONG)p;
+								bret = true;
+								break;
+							}
+						}
+
+						HWND hchile = ::GetWindow(p, GW_CHILD);
+						if (hchile != NULL) {
+							const wchar_t* classname = NULL;
+							const wchar_t* titles = NULL;
+							if (wcslen(class_name) > 0) classname = class_name;
+							if (wcslen(title) > 0) titles = titles;
+							DWORD dret = FindChildWnd(hchile, titles, classname, NULL, false,
+								false, process_name);
+							if (dret > 0) {
+								rethwnd = (LONG)dret;
+								bret = true;
+								break;
+							}
+						}
+					}
+				}
+			}
+			p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+		}
+	}
+	else if (Pid > 0) {
+		HWND p = ::GetWindow(GetDesktopWindow(), GW_CHILD);  //获取桌面窗口的子窗口
+		p = ::GetWindow(p, GW_HWNDFIRST);
+		while (p != NULL) {
+			if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+				DWORD npid = 0;
+				GetWindowThreadProcessId(p, &npid);
+				if (Pid == npid) {
+					if (wcslen(class_name) < 1 && wcslen(title) < 1) {
+						rethwnd = (LONG)p;
+						bret = true;
+						break;
+					}
+					else {
+						wchar_t WindowClassName[MAX_PATH] = { 0 };
+						::GetClassName(p, WindowClassName, MAX_PATH);
+						wchar_t WindowTitle[MAX_PATH] = { 0 };
+						::GetWindowText(p, WindowTitle, MAX_PATH);
+						if (wcslen(WindowClassName) > 1 && wcslen(WindowTitle) > 1) {
+							wchar_t* strfindclass =
+								wcsstr(WindowClassName, class_name);  //模糊匹配
+							wchar_t* strfindtitle = wcsstr(WindowTitle, title);  //模糊匹配
+							if ((wcslen(class_name) >= 1 && strfindclass) ||
+								(wcslen(title) >= 1 && strfindtitle)) {
+								rethwnd = (LONG)p;
+								bret = true;
+								break;
+							}
+						}
+						HWND hchile = ::GetWindow(p, GW_CHILD);
+						if (hchile != NULL) {
+							const wchar_t* classname = NULL;
+							const wchar_t* titles = NULL;
+							if (wcslen(class_name) > 0) classname = class_name;
+							if (wcslen(title) > 0) titles = titles;
+							DWORD dret = FindChildWnd(hchile, titles, classname, NULL, false,
+								false, process_name);
+							if (dret > 0) {
+								rethwnd = (LONG)dret;
+								bret = true;
+								break;
+							}
+						}
+					}
+				}
+			}
+			p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+		}
+	}
+
+	return bret;
 }
-bool WinApi::GetClientRect(LONG hwnd, LONG &x, LONG &y, LONG &x1, LONG &y1) {
-  bool bret = false;
-  RECT clientrect;
-  if (IsWindow((HWND)hwnd)) {
-    ::GetClientRect((HWND)hwnd, &clientrect);
-    POINT point;
-    point.x = clientrect.left;
-    point.y = clientrect.top;
-    ::ClientToScreen((HWND)hwnd, &point);
-    x = point.x;
-    y = point.y;
-    point.x = clientrect.right;
-    point.y = clientrect.bottom;
-    ::ClientToScreen((HWND)hwnd, &point);
-    x1 = point.x;
-    y1 = point.y;
-    bret = true;
-  }
-
-  return bret;
+
+bool WinApi::GetClientRect(LONG hwnd, LONG& x, LONG& y, LONG& x1, LONG& y1)
+{
+	bool bret = false;
+	RECT clientrect;
+	if (IsWindow((HWND)hwnd)) {
+		::GetClientRect((HWND)hwnd, &clientrect);
+		POINT point;
+		point.x = clientrect.left;
+		point.y = clientrect.top;
+		::ClientToScreen((HWND)hwnd, &point);
+		x = point.x;
+		y = point.y;
+		point.x = clientrect.right;
+		point.y = clientrect.bottom;
+		::ClientToScreen((HWND)hwnd, &point);
+		x1 = point.x;
+		y1 = point.y;
+		bret = true;
+	}
+
+	return bret;
 }
-bool WinApi::GetClientSize(LONG hwnd, LONG &width, LONG &height) {
-  bool bret = false;
-  RECT clientrect;
-  if (IsWindow((HWND)hwnd)) {
-    ::GetClientRect((HWND)hwnd, &clientrect);
-    width = clientrect.right - clientrect.left;
-    height = clientrect.bottom - clientrect.top;
-    bret = true;
-  }
-  return bret;
+
+bool WinApi::GetClientSize(LONG hwnd, LONG& width, LONG& height)
+{
+	bool bret = false;
+	RECT clientrect;
+	if (IsWindow((HWND)hwnd)) {
+		::GetClientRect((HWND)hwnd, &clientrect);
+		width = clientrect.right - clientrect.left;
+		height = clientrect.bottom - clientrect.top;
+		bret = true;
+	}
+	return bret;
 }
-bool WinApi::GetMousePointWindow(LONG &rethwnd, LONG x, LONG y) {
-  bool bret = false;
-  rethwnd = 0;
-  POINT point;
-  if ((x != -1 && y != -1)) {
-    point.x = x;
-    point.y = y;
-  } else {
-    ::GetCursorPos(&point);
-  }
-  rethwnd = (DWORD)::WindowFromPoint(point);
-  if (rethwnd == NULL) {
-    HWND p = ::GetWindow(GetDesktopWindow(), GW_CHILD);  //获取桌面窗口的子窗口
-    p = ::GetWindow(p, GW_HWNDFIRST);
-    while (p != NULL) {
-      if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
-        RECT rc;
-        ::GetWindowRect(p, &rc);
-        if ((rc.top <= point.y) && (rc.left <= point.x) &&
-            (rc.right >= (point.x - rc.left)) &&
-            (rc.bottom >= (point.y - rc.top))) {
-          wchar_t WindowClass[MAX_PATH] = {0};
-          ::GetClassName(p, WindowClass, MAX_PATH);
-          // if((windowpoint.x==0||windowpoint.x<rc.left)&&wcscmp(WindowClass,L"CabinetWClass")!=0)
-          // //IE框窗体排除在外
-          if (wcscmp(WindowClass, L"CabinetWClass") != 0)  // IE框窗体排除在外
-          {
-            rethwnd = (DWORD)p;
-            bret = true;
-            break;
-          }
-        }
-      }
-      p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
-    }
-  } else
-    bret = true;
-
-  return bret;
+
+bool WinApi::GetMousePointWindow(LONG& rethwnd, LONG x, LONG y)
+{
+	bool bret = false;
+	rethwnd = 0;
+	POINT point;
+	if ((x != -1 && y != -1)) {
+		point.x = x;
+		point.y = y;
+	}
+	else {
+		::GetCursorPos(&point);
+	}
+	rethwnd = (DWORD)::WindowFromPoint(point);
+	if (rethwnd == NULL) {
+		HWND p = ::GetWindow(GetDesktopWindow(), GW_CHILD);  //获取桌面窗口的子窗口
+		p = ::GetWindow(p, GW_HWNDFIRST);
+		while (p != NULL) {
+			if (::IsWindowVisible(p) && ::GetWindow(p, GW_OWNER) == 0) {
+				RECT rc;
+				::GetWindowRect(p, &rc);
+				if ((rc.top <= point.y) && (rc.left <= point.x) &&
+					(rc.right >= (point.x - rc.left)) &&
+					(rc.bottom >= (point.y - rc.top))) {
+					wchar_t WindowClass[MAX_PATH] = { 0 };
+					::GetClassName(p, WindowClass, MAX_PATH);
+					// if((windowpoint.x==0||windowpoint.x<rc.left)&&wcscmp(WindowClass,L"CabinetWClass")!=0)
+					// //IE框窗体排除在外
+					if (wcscmp(WindowClass, L"CabinetWClass") != 0)  // IE框窗体排除在外
+					{
+						rethwnd = (DWORD)p;
+						bret = true;
+						break;
+					}
+				}
+			}
+			p = ::GetWindow(p, GW_HWNDNEXT);  //获取下一个窗口
+		}
+	}
+	else
+		bret = true;
+
+	return bret;
 }
 
 int WinApi::GetProcessNumber()  //获取CPU个数
 {
-  SYSTEM_INFO info;
-  GetSystemInfo(&info);
-  return (int)info.dwNumberOfProcessors;
+	SYSTEM_INFO info;
+	GetSystemInfo(&info);
+	return (int)info.dwNumberOfProcessors;
 }
 
 // 时间格式转换
-__int64 WinApi::FileTimeToInt64(const FILETIME &time) {
-  ULARGE_INTEGER tt;
-  tt.LowPart = time.dwLowDateTime;
-  tt.HighPart = time.dwHighDateTime;
-  return (tt.QuadPart);
+__int64 WinApi::FileTimeToInt64(const FILETIME& time) 
+{
+	ULARGE_INTEGER tt;
+	tt.LowPart = time.dwLowDateTime;
+	tt.HighPart = time.dwHighDateTime;
+	return (tt.QuadPart);
 }
 
 double WinApi::get_cpu_usage(DWORD ProcessID)  //获取指定进程CPU使用率
 {
-  // cpu数量
-  static int processor_count_ = -1;
-  //上一次的时间
-  static __int64 last_time_ = 0;
-  static __int64 last_system_time_ = 0;
-
-  FILETIME now;
-  FILETIME creation_time;
-  FILETIME exit_time;
-  FILETIME kernel_time;
-  FILETIME user_time;
-  __int64 system_time;
-  __int64 time;
-  // 	__int64 system_time_delta;
-  // 	__int64 time_delta;
-
-  double cpu = -1;
-
-  if (processor_count_ == -1) {
-    processor_count_ = GetProcessNumber();
-  }
-
-  GetSystemTimeAsFileTime(&now);
-
-  // HANDLE hProcess =
-  // OpenProcess(PROCESS_QUERY_INFORMATION/*PROCESS_ALL_ACCESS*/, false,
-  // ProcessID);
-  HANDLE hProcess = NULL;
-
-  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
-                         ProcessID);
-
-  if (!hProcess) {
-    return -1;
-  }
-  if (!GetProcessTimes(hProcess, &creation_time, &exit_time, &kernel_time,
-                       &user_time)) {
-    return -1;
-  }
-  system_time = (FileTimeToInt64(kernel_time) + FileTimeToInt64(user_time)) /
-                processor_count_;  // CPU使用时间
-  time = FileTimeToInt64(now);     //现在的时间
-
-  last_system_time_ = system_time;
-  last_time_ = time;
-  CloseHandle(hProcess);
-
-  Sleep(1000);
-
-  // hProcess = OpenProcess(PROCESS_QUERY_INFORMATION/*PROCESS_ALL_ACCESS*/,
-  // false, ProcessID);
-
-  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
-                         ProcessID);
-
-  if (!hProcess) {
-    return -1;
-  }
-  if (!GetProcessTimes(hProcess, &creation_time, &exit_time, &kernel_time,
-                       &user_time)) {
-    return -1;
-  }
-  GetSystemTimeAsFileTime(&now);
-  system_time = (FileTimeToInt64(kernel_time) + FileTimeToInt64(user_time)) /
-                processor_count_;  // CPU使用时间
-  time = FileTimeToInt64(now);     //现在的时间
-
-  CloseHandle(hProcess);
-
-  cpu = ((double)(system_time - last_system_time_) /
-         (double)(time - last_time_)) *
-        100;
-  return cpu;
+	// cpu数量
+	static int processor_count_ = -1;
+	//上一次的时间
+	static __int64 last_time_ = 0;
+	static __int64 last_system_time_ = 0;
+
+	FILETIME now;
+	FILETIME creation_time;
+	FILETIME exit_time;
+	FILETIME kernel_time;
+	FILETIME user_time;
+	__int64 system_time;
+	__int64 time;
+	// 	__int64 system_time_delta;
+	// 	__int64 time_delta;
+
+	double cpu = -1;
+	if (processor_count_ == -1) {
+		processor_count_ = GetProcessNumber();
+	}
+
+	GetSystemTimeAsFileTime(&now);
+
+	// HANDLE hProcess =
+	// OpenProcess(PROCESS_QUERY_INFORMATION/*PROCESS_ALL_ACCESS*/, false,
+	// ProcessID);
+	HANDLE hProcess = NULL;
+	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
+		ProcessID);
+
+	if (!hProcess) {
+		return -1;
+	}
+
+	if (!GetProcessTimes(hProcess, &creation_time, &exit_time, &kernel_time,
+		&user_time)) {
+		return -1;
+	}
+	system_time = (FileTimeToInt64(kernel_time) + FileTimeToInt64(user_time)) /
+		processor_count_;  // CPU使用时间
+	time = FileTimeToInt64(now);     //现在的时间
+
+	last_system_time_ = system_time;
+	last_time_ = time;
+	CloseHandle(hProcess);
+
+	Sleep(1000);
+
+	// hProcess = OpenProcess(PROCESS_QUERY_INFORMATION/*PROCESS_ALL_ACCESS*/,
+	// false, ProcessID);
+
+	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
+		ProcessID);
+
+	if (!hProcess) {
+		return -1;
+	}
+	if (!GetProcessTimes(hProcess, &creation_time, &exit_time, &kernel_time,
+		&user_time)) {
+		return -1;
+	}
+	GetSystemTimeAsFileTime(&now);
+	system_time = (FileTimeToInt64(kernel_time) + FileTimeToInt64(user_time)) /
+		processor_count_;  // CPU使用时间
+	time = FileTimeToInt64(now);     //现在的时间
+
+	CloseHandle(hProcess);
+
+	cpu = ((double)(system_time - last_system_time_) /
+		(double)(time - last_time_)) *
+		100;
+	return cpu;
 }
 
 //或者指定进程内存使用率
-DWORD WinApi::GetMemoryInfo(DWORD ProcessID) {
-  PROCESS_MEMORY_COUNTERS pmc;
-  DWORD memoryInK = 0;
-  HANDLE hProcess = NULL;
+DWORD WinApi::GetMemoryInfo(DWORD ProcessID) 
+{
+	PROCESS_MEMORY_COUNTERS pmc;
+	DWORD memoryInK = 0;
+	HANDLE hProcess = NULL;
 
-  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
-                         ProcessID);
+	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
+		ProcessID);
 
-  if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) {
-    // memoryInK = pmc.WorkingSetSize/1024;		//单位为k
-    memoryInK = pmc.WorkingSetSize;
-  }
+	if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) {
+		// memoryInK = pmc.WorkingSetSize/1024;		//单位为k
+		memoryInK = pmc.WorkingSetSize;
+	}
 
-  CloseHandle(hProcess);
-  return memoryInK;
+	CloseHandle(hProcess);
+	return memoryInK;
 }
 
-bool WinApi::GetProcessInfo(LONG pid, wchar_t *retstring) {
-  bool bret = false;
-  wchar_t process_name[MAX_PATH] = {0};
-  wchar_t process_path[MAX_PATH] = {0};
-  DWORD cpu = 0;
-  DWORD meminfo = 0;
-
-  int nItem = 0;  // 项计数
-  PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};
-  HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-  if (hProcessSnap == INVALID_HANDLE_VALUE) return FALSE;
-  if (::Process32First(hProcessSnap, &pe32)) {
-    do {
-      if (pe32.th32ProcessID == pid) {
-        wcscpy(process_name, pe32.szExeFile);
-        break;
-      }
-
-    } while (::Process32Next(hProcessSnap, &pe32));
-  }
-  ::CloseHandle(hProcessSnap);
-  if (wcslen(process_name) < 1) return bret;
-
-  // TSRuntime::GetRemoteModulePath(process_name, pid, process_path);
-  cpu = (DWORD)get_cpu_usage(pid);
-  meminfo = (DWORD)GetMemoryInfo(pid);
-
-  swprintf(retstring, L"%s|%s|%d|%d", process_name, process_path, cpu, meminfo);
-
-  return bret;
+bool WinApi::GetProcessInfo(LONG pid, wchar_t* retstring) 
+{
+	bool bret = false;
+	wchar_t process_name[MAX_PATH] = { 0 };
+	wchar_t process_path[MAX_PATH] = { 0 };
+	DWORD cpu = 0;
+	DWORD meminfo = 0;
+
+	int nItem = 0;  // 项计数
+	PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) };
+	HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+	if (hProcessSnap == INVALID_HANDLE_VALUE) return FALSE;
+	if (::Process32First(hProcessSnap, &pe32)) {
+		do {
+			if (pe32.th32ProcessID == pid) {
+				wcscpy(process_name, pe32.szExeFile);
+				break;
+			}
+
+		} while (::Process32Next(hProcessSnap, &pe32));
+	}
+	::CloseHandle(hProcessSnap);
+	if (wcslen(process_name) < 1) return bret;
+
+	// TSRuntime::GetRemoteModulePath(process_name, pid, process_path);
+	cpu = (DWORD)get_cpu_usage(pid);
+	meminfo = (DWORD)GetMemoryInfo(pid);
+
+	swprintf(retstring, L"%s|%s|%d|%d", process_name, process_path, cpu, meminfo);
+
+	return bret;
 }
-bool WinApi::GetProcesspath(DWORD ProcessID, wchar_t *process_path) {
-  HANDLE hProcess = NULL;
 
-  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
-                         ProcessID);
+bool WinApi::GetProcesspath(DWORD ProcessID, wchar_t* process_path) 
+{
+	HANDLE hProcess = NULL;
 
-  HMODULE hMods = NULL;
-  DWORD cbNeededModule = 0;
-  EnumProcessModules(hProcess, &hMods, sizeof(hMods), &cbNeededModule);
-  GetModuleFileNameEx(hProcess, hMods, process_path, MAX_PATH);
+	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,
+		ProcessID);
 
-  return true;
-}
-bool WinApi::GetWindow(LONG hwnd, LONG flag, LONG &rethwnd) {
-  bool bret = false;
-  rethwnd = 0;
-  HWND wnd = (HWND)hwnd;
-  if (IsWindow(wnd) == false) return bret;
-  DWORD type = -1;
-  if (flag == 0)  // 0:获取父窗口
-    rethwnd = (LONG)::GetParent(wnd);
-  else if (flag == 1)  //获取第一个儿子窗口
-    type = GW_CHILD;
-  else if (flag == 2)  //获取First 窗口
-    type = GW_HWNDFIRST;
-  else if (flag == 3)  //获取Last窗口
-    type = GW_HWNDLAST;
-  else if (flag == 4)  //获取下一个窗口
-    type = GW_HWNDNEXT;
-  else if (flag == 5)  //获取上一个窗口
-    type = GW_HWNDPREV;
-  else if (flag == 6)  //获取拥有者窗口
-    type = GW_OWNER;
-  else if (flag == 7)  //获取顶层窗口
-  {
-    // rethwnd = (LONG)::GetForegroundWindow();
-    HWND next = NULL, current = (HWND)hwnd;
-    while (next = ::GetParent(current)) current = next;
-    rethwnd = (long)current;
-    return ::IsWindow(current);
-  }
-
-  if (type != -1) rethwnd = (LONG)::GetWindow(wnd, (UINT)type);
-
-  if (rethwnd != 0) bret = true;
-
-  return bret;
-}
+	HMODULE hMods = NULL;
+	DWORD cbNeededModule = 0;
+	EnumProcessModules(hProcess, &hMods, sizeof(hMods), &cbNeededModule);
+	GetModuleFileNameEx(hProcess, hMods, process_path, MAX_PATH);
 
-bool WinApi::GetWindowState(LONG hwnd, LONG flag) {
-  bool bret = false;
-  HWND wnd = (HWND)hwnd;
-  if (flag == 0)  // 0://判断窗口是否存在
-    bret = ::IsWindow(wnd);
-  else if (flag == 1)  //判断窗口是否处于激活
-  {
-    if (::GetActiveWindow() == wnd) bret = true;
-  } else if (flag == 2)  // 2 : 判断窗口是否可见
-    bret = ::IsWindowVisible(wnd);
-  else if (flag == 3)  // 3 : 判断窗口是否最小化
-    bret = ::IsIconic(wnd);
-  else if (flag == 4)  // 4 : 判断窗口是否最大化
-    bret = ::IsZoomed(wnd);
-  else if (flag == 5)  // 5 : 判断窗口是否置顶
-  {
-    if (::GetForegroundWindow() == wnd) bret = true;
-  } else if (flag == 6)  // 6 : 判断窗口是否无响应
-    bret = ::IsHungAppWindow(wnd);
-  else if (flag == 7)  //判断窗口是否可用(灰色为不可用)
-    bret = ::IsWindowEnabled(wnd);
-
-  return bret;
+	return true;
 }
 
-bool WinApi::SendPaste(LONG hwnd) {
-  bool bret = true;
-  HANDLE hClip;
-  char *chBuffer = NULL;
-  if (OpenClipboard(NULL)) {
-    //从剪贴板中取出一个内存的句柄
-    hClip = GetClipboardData(CF_TEXT);
-    //定义字符型指针变量用来保存内存块中的数据
-    //对内存块进行加锁,将内存句柄值转化为一个指针,并将内存块的引用计数器加一,内存中的数据也返回到指针型变量中
-    chBuffer = (char *)GlobalLock(hClip);
-    //将数据保存到字符型变量中
-    //将内存块的引用计数器减一
-    GlobalUnlock(hClip);
-    //关闭剪贴板,释放剪贴板资源的占用权
-    CloseClipboard();
-  }
-  // anscii 转 unicode
-  DWORD num = MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, NULL, 0);
-  wchar_t *wword = new wchar_t[num + 1];          //动态的申请空间存字
-  memset(wword, 0, (num + 1) * sizeof(wchar_t));  //初始化动作
-  MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, wword, num);
-
-  int len = wcslen(wword);
-  // MessageBoxA(NULL,tts,tts,NULL);
-  for (int i = 0; i < len; i++) {
-    ::SendMessage((HWND)hwnd, WM_CHAR, (WPARAM)wword[i], (LPARAM)1);
-    Sleep(10);
-  }
-  delete[] wword;
-
-  return bret;
+bool WinApi::GetWindow(LONG hwnd, LONG flag, LONG& rethwnd) 
+{
+	bool bret = false;
+	rethwnd = 0;
+	HWND wnd = (HWND)hwnd;
+	if (IsWindow(wnd) == false) return bret;
+	DWORD type = -1;
+	if (flag == 0)  // 0:获取父窗口
+		rethwnd = (LONG)::GetParent(wnd);
+	else if (flag == 1)  //获取第一个儿子窗口
+		type = GW_CHILD;
+	else if (flag == 2)  //获取First 窗口
+		type = GW_HWNDFIRST;
+	else if (flag == 3)  //获取Last窗口
+		type = GW_HWNDLAST;
+	else if (flag == 4)  //获取下一个窗口
+		type = GW_HWNDNEXT;
+	else if (flag == 5)  //获取上一个窗口
+		type = GW_HWNDPREV;
+	else if (flag == 6)  //获取拥有者窗口
+		type = GW_OWNER;
+	else if (flag == 7)  //获取顶层窗口
+	{
+		// rethwnd = (LONG)::GetForegroundWindow();
+		HWND next = NULL, current = (HWND)hwnd;
+		while (next = ::GetParent(current)) current = next;
+		rethwnd = (long)current;
+		return ::IsWindow(current);
+	}
+
+	if (type != -1) rethwnd = (LONG)::GetWindow(wnd, (UINT)type);
+
+	if (rethwnd != 0) bret = true;
+
+	return bret;
 }
 
-bool WinApi::SetWindowSize(LONG hwnd, LONG width, LONG hight, int type) {
-  bool bret = false;
-  if (type == 0)  // SetClientSize
-  {
-    RECT rectProgram, rectClient;
-    HWND hWnd = (HWND)hwnd;
-    ::GetWindowRect(hWnd, &rectProgram);  //获得程序窗口位于屏幕坐标
-    ::GetClientRect(hWnd, &rectClient);   //获得客户区坐标
-    //非客户区宽,高
-    int nWidth = rectProgram.right - rectProgram.left -
-                 (rectClient.right - rectClient.left);
-    int nHeiht = rectProgram.bottom - rectProgram.top -
-                 (rectClient.bottom - rectClient.top);
-    nWidth += width;
-    nHeiht += hight;
-    rectProgram.right = nWidth;
-    rectProgram.bottom = nHeiht;
-    int showToScreenx =
-        GetSystemMetrics(SM_CXSCREEN) / 2 - nWidth / 2;  //居中处理
-    int showToScreeny = GetSystemMetrics(SM_CYSCREEN) / 2 - nHeiht / 2;
-    bret = ::MoveWindow(hWnd, showToScreenx, showToScreeny, rectProgram.right,
-                        rectProgram.bottom, false);
-  } else  // SetWindowSize
-  {
-    RECT rectClient;
-    HWND hWnd = (HWND)hwnd;
-    ::GetWindowRect(hWnd, &rectClient);  //获得程序窗口位于屏幕坐标
-    bret = ::MoveWindow(hWnd, rectClient.left, rectClient.top, width, hight,
-                        false);
-  }
-  return bret;
+bool WinApi::GetWindowState(LONG hwnd, LONG flag) 
+{
+	bool bret = false;
+	HWND wnd = (HWND)hwnd;
+	if (flag == 0)  // 0://判断窗口是否存在
+		bret = ::IsWindow(wnd);
+	else if (flag == 1)  //判断窗口是否处于激活
+	{
+		if (::GetActiveWindow() == wnd) bret = true;
+	}
+	else if (flag == 2)  // 2 : 判断窗口是否可见
+		bret = ::IsWindowVisible(wnd);
+	else if (flag == 3)  // 3 : 判断窗口是否最小化
+		bret = ::IsIconic(wnd);
+	else if (flag == 4)  // 4 : 判断窗口是否最大化
+		bret = ::IsZoomed(wnd);
+	else if (flag == 5)  // 5 : 判断窗口是否置顶
+	{
+		if (::GetForegroundWindow() == wnd) bret = true;
+	}
+	else if (flag == 6)  // 6 : 判断窗口是否无响应
+		bret = ::IsHungAppWindow(wnd);
+	else if (flag == 7)  //判断窗口是否可用(灰色为不可用)
+		bret = ::IsWindowEnabled(wnd);
+
+	return bret;
 }
 
-bool WinApi::SetWindowState(LONG hwnd, LONG flag, LONG rethwnd) {
-  bool bret = false;
-  HWND hWnd = (HWND)hwnd;
-  if (IsWindow(hWnd) == false) return bret;
-  int type = -1;
-  type = flag;
-  if (flag == 0)  //关闭指定窗口
-    ::SendMessage(hWnd, WM_CLOSE, 0, 0);
-  else if (flag == 1)  //激活指定窗口
-  {
-    ::ShowWindow(hWnd, SW_SHOW);
-    ::SetForegroundWindow(hWnd);
-  } else if (flag == 2)  //最小化指定窗口,但不激活
-    ::ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
-  else if (flag == 3)  //最小化指定窗口,并释放内存,但同时也会激活窗口
-    ::ShowWindow(hWnd, SW_SHOWMINIMIZED);
-  else if (flag == 4)  //最大化指定窗口,同时激活窗口.
-    ::ShowWindow(hWnd, SW_SHOWMAXIMIZED);
-  else if (flag == 5)  //恢复指定窗口 ,但不激活
-    ::ShowWindow(hWnd, SW_SHOWNOACTIVATE);
-  else if (flag == 6)  //隐藏指定窗口
-    ::ShowWindow(hWnd, SW_HIDE);
-  else if (flag == 7)  //显示指定窗口
-  {
-    ::ShowWindow(hWnd, SW_SHOW);
-    ::SetForegroundWindow(hWnd);
-  } else if (flag == 8)  //置顶指定窗口
-    ::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,
-                   SWP_NOMOVE | SWP_NOSIZE);  //窗口置顶
-  else if (flag == 9)                         // 9 : 取消置顶指定窗口
-    ::SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
-  else if (flag == 10)  //禁止指定窗口
-    ::EnableWindow(hWnd, false);
-  else if (flag == 11)  //取消禁止指定窗口
-    ::EnableWindow(hWnd, true);
-  else if (flag == 12)  // 12 : 恢复并激活指定窗口
-    ::ShowWindow(hWnd, SW_RESTORE);
-  else if (flag == 13)  // 13 : 强制结束窗口所在进程.
-  {
-    DWORD pid = 0;
-    ::GetWindowThreadProcessId(hWnd, &pid);
-    // TSRuntime::EnablePrivilege(L"SeDebugPrivilege", true);
-    HANDLE hprocess = NULL;
-
-    hprocess = ::OpenProcess(PROCESS_ALL_ACCESS, false, pid);
-
-    ::TerminateProcess(hprocess, 0);
-  } else if (flag == 14)  // 14 : 闪烁指定的窗口
-  {
-    FLASHWINFO fInfo;
-    fInfo.cbSize = sizeof(FLASHWINFO);
-    fInfo.dwFlags =
-        FLASHW_ALL |
-        FLASHW_TIMERNOFG;  //这里是闪动窗标题和任务栏按钮,直到用户激活窗体
-    fInfo.dwTimeout = 0;
-    fInfo.hwnd = hWnd;
-    fInfo.uCount = 0xffffff;
-    FlashWindowEx(&fInfo);
-  } else if (flag == 15)  //使指定的窗口获取输入焦点
-  {
-    ::ShowWindow(hWnd, SW_SHOW);
-    ::SetFocus(hWnd);
-  }
-
-  if (type >= 0 && type < 16) bret = true;
-
-  return bret;
+bool WinApi::SendPaste(LONG hwnd)
+{
+	bool bret = true;
+	HANDLE hClip;
+	char* chBuffer = NULL;
+	if (OpenClipboard(NULL)) {
+		//从剪贴板中取出一个内存的句柄
+		hClip = GetClipboardData(CF_TEXT);
+		//定义字符型指针变量用来保存内存块中的数据
+		//对内存块进行加锁,将内存句柄值转化为一个指针,并将内存块的引用计数器加一,内存中的数据也返回到指针型变量中
+		chBuffer = (char*)GlobalLock(hClip);
+		//将数据保存到字符型变量中
+		//将内存块的引用计数器减一
+		GlobalUnlock(hClip);
+		//关闭剪贴板,释放剪贴板资源的占用权
+		CloseClipboard();
+	}
+	// anscii 转 unicode
+	DWORD num = MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, NULL, 0);
+	wchar_t* wword = new wchar_t[num + 1];          //动态的申请空间存字
+	memset(wword, 0, (num + 1) * sizeof(wchar_t));  //初始化动作
+	MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, wword, num);
+
+	int len = wcslen(wword);
+	// MessageBoxA(NULL,tts,tts,NULL);
+	for (int i = 0; i < len; i++) {
+		::SendMessage((HWND)hwnd, WM_CHAR, (WPARAM)wword[i], (LPARAM)1);
+		Sleep(10);
+	}
+	delete[] wword;
+
+	return bret;
 }
 
-bool WinApi::SetWindowTransparent(LONG hwnd, LONG trans) {
-  bool bret = false;
-
-  COLORREF crKey = NULL;
-  DWORD dwFlags = 0;
-  BYTE bAlpha = 0;
-  if (trans < 0) trans = 0;
-  if (trans > 255) trans = 255;
-  //...
-  /*typedef bool(__stdcall  *  mySetLayeredWindowAttributes)(
-          HWND hwnd,
-          COLORREF pcrKey,
-          BYTE pbAlpha,
-          DWORD pdwFlags);
-  mySetLayeredWindowAttributes obj_SetLayeredWindowAttributes = NULL;
-  HINSTANCE hlibrary;
-  hlibrary = LoadLibrary(_T("user32.dll"));
-  obj_SetLayeredWindowAttributes =
-  (mySetLayeredWindowAttributes)GetProcAddress(hlibrary,
-  "SetLayeredWindowAttributes");*/
-
-  SetWindowLong((HWND)hwnd, GWL_EXSTYLE, 0x80001);
-  bret = SetLayeredWindowAttributes((HWND)hwnd, crKey, trans, 2);
-
-  return bret;
+bool WinApi::SetWindowSize(LONG hwnd, LONG width, LONG hight, int type)
+{
+	bool bret = false;
+	if (type == 0)  // SetClientSize
+	{
+		RECT rectProgram, rectClient;
+		HWND hWnd = (HWND)hwnd;
+		::GetWindowRect(hWnd, &rectProgram);  //获得程序窗口位于屏幕坐标
+		::GetClientRect(hWnd, &rectClient);   //获得客户区坐标
+		//非客户区宽,高
+		int nWidth = rectProgram.right - rectProgram.left -
+			(rectClient.right - rectClient.left);
+		int nHeiht = rectProgram.bottom - rectProgram.top -
+			(rectClient.bottom - rectClient.top);
+		nWidth += width;
+		nHeiht += hight;
+		rectProgram.right = nWidth;
+		rectProgram.bottom = nHeiht;
+		int showToScreenx =
+			GetSystemMetrics(SM_CXSCREEN) / 2 - nWidth / 2;  //居中处理
+		int showToScreeny = GetSystemMetrics(SM_CYSCREEN) / 2 - nHeiht / 2;
+		bret = ::MoveWindow(hWnd, showToScreenx, showToScreeny, rectProgram.right,
+			rectProgram.bottom, false);
+	}
+	else  // SetWindowSize
+	{
+		RECT rectClient;
+		HWND hWnd = (HWND)hwnd;
+		::GetWindowRect(hWnd, &rectClient);  //获得程序窗口位于屏幕坐标
+		bret = ::MoveWindow(hWnd, rectClient.left, rectClient.top, width, hight,
+			false);
+	}
+	return bret;
 }
 
-bool WinApi::SetClipboard(wchar_t *values) {
-  bool bret = false;
-  int n = ::WideCharToMultiByte(CP_ACP, 0, values, -1, NULL, 0, NULL, NULL);
-  char *chcontent = new char[n + 1];
-  memset(chcontent, 0, sizeof(char) * n + 1);
-  WideCharToMultiByte(CP_ACP, 0, values, -1, chcontent, n, NULL, NULL);
-
-  if (OpenClipboard(NULL)) {
-    //将剪贴板内容清空
-    EmptyClipboard();
-    //字节长度
-    int leng = strlen(chcontent) + 1;
-    //在堆上分配可移动的内存块,程序返回一个内存句柄
-    HANDLE hClip = GlobalAlloc(GHND | GMEM_SHARE, leng);
-    //定义指向字符型的指针变量
-    char *buff;
-    //对分配的内存块进行加锁,将内存块句柄转化成一个指针,并将相应的引用计数器加一
-    buff = (char *)GlobalLock(hClip);
-    //将用户输入的数据拷贝到指针变量中,实际上就是拷贝到分配的内存块中
-    memcpy(buff, chcontent, leng);
-    buff[leng - 1] = 0;
-    //数据写入完毕,进行解锁操作,并将引用计数器数字减一
-    GlobalUnlock(hClip);
-    //将存放有数据的内存块放入剪贴板的资源管理中
-    HANDLE help = SetClipboardData(CF_TEXT, hClip);
-    //关闭剪贴板,释放剪贴板资源的占用权
-    CloseClipboard();
-    // MessageBox(0,L"已将数据存入剪贴板",L"剪切扳",0);
-    if (help != NULL) {
-      bret = true;
-    } else {
-      bret = false;
-    }
-  }
-  delete[] chcontent;
-  return bret;
+bool WinApi::SetWindowState(LONG hwnd, LONG flag, LONG rethwnd) 
+{
+	bool bret = false;
+	HWND hWnd = (HWND)hwnd;
+	if (IsWindow(hWnd) == false) return bret;
+	int type = -1;
+	type = flag;
+	if (flag == 0)  //关闭指定窗口
+		::SendMessage(hWnd, WM_CLOSE, 0, 0);
+	else if (flag == 1)  //激活指定窗口
+	{
+		::ShowWindow(hWnd, SW_SHOW);
+		::SetForegroundWindow(hWnd);
+	}
+	else if (flag == 2)  //最小化指定窗口,但不激活
+		::ShowWindow(hWnd, SW_SHOWMINNOACTIVE);
+	else if (flag == 3)  //最小化指定窗口,并释放内存,但同时也会激活窗口
+		::ShowWindow(hWnd, SW_SHOWMINIMIZED);
+	else if (flag == 4)  //最大化指定窗口,同时激活窗口.
+		::ShowWindow(hWnd, SW_SHOWMAXIMIZED);
+	else if (flag == 5)  //恢复指定窗口 ,但不激活
+		::ShowWindow(hWnd, SW_SHOWNOACTIVATE);
+	else if (flag == 6)  //隐藏指定窗口
+		::ShowWindow(hWnd, SW_HIDE);
+	else if (flag == 7)  //显示指定窗口
+	{
+		::ShowWindow(hWnd, SW_SHOW);
+		::SetForegroundWindow(hWnd);
+	}
+	else if (flag == 8)  //置顶指定窗口
+		::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,
+			SWP_NOMOVE | SWP_NOSIZE);  //窗口置顶
+	else if (flag == 9)                         // 9 : 取消置顶指定窗口
+		::SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+	else if (flag == 10)  //禁止指定窗口
+		::EnableWindow(hWnd, false);
+	else if (flag == 11)  //取消禁止指定窗口
+		::EnableWindow(hWnd, true);
+	else if (flag == 12)  // 12 : 恢复并激活指定窗口
+		::ShowWindow(hWnd, SW_RESTORE);
+	else if (flag == 13)  // 13 : 强制结束窗口所在进程.
+	{
+		DWORD pid = 0;
+		::GetWindowThreadProcessId(hWnd, &pid);
+		// TSRuntime::EnablePrivilege(L"SeDebugPrivilege", true);
+		HANDLE hprocess = NULL;
+
+		hprocess = ::OpenProcess(PROCESS_ALL_ACCESS, false, pid);
+
+		::TerminateProcess(hprocess, 0);
+	}
+	else if (flag == 14)  // 14 : 闪烁指定的窗口
+	{
+		FLASHWINFO fInfo;
+		fInfo.cbSize = sizeof(FLASHWINFO);
+		fInfo.dwFlags =
+			FLASHW_ALL |
+			FLASHW_TIMERNOFG;  //这里是闪动窗标题和任务栏按钮,直到用户激活窗体
+		fInfo.dwTimeout = 0;
+		fInfo.hwnd = hWnd;
+		fInfo.uCount = 0xffffff;
+		FlashWindowEx(&fInfo);
+	}
+	else if (flag == 15)  //使指定的窗口获取输入焦点
+	{
+		::ShowWindow(hWnd, SW_SHOW);
+		::SetFocus(hWnd);
+	}
+
+	if (type >= 0 && type < 16) bret = true;
+
+	return bret;
 }
 
-bool WinApi::GetClipboard(wchar_t *retstr) {
-  bool bret = false;
-  HANDLE hClip;
-  char *chBuffer = NULL;
-  if (OpenClipboard(NULL)) {
-    //从剪贴板中取出一个内存的句柄
-    hClip = GetClipboardData(CF_TEXT);
-    //定义字符型指针变量用来保存内存块中的数据
-
-    //对内存块进行加锁,将内存句柄值转化为一个指针,并将内存块的引用计数器加一,内存中的数据也返回到指针型变量中
-    chBuffer = (char *)GlobalLock(hClip);
-
-    //将数据保存到字符型变量中
-    //将内存块的引用计数器减一
-    GlobalUnlock(hClip);
-    //关闭剪贴板,释放剪贴板资源的占用权
-    CloseClipboard();
-  }
-
-  DWORD num = MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, NULL, 0);
-  wchar_t *wword = new wchar_t[num + 1];          //动态的申请空间存字
-  memset(wword, 0, (num + 1) * sizeof(wchar_t));  //初始化动作
-  MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, wword, num);
-
-  if (num < MAX_PATH * 4 - 1) wcscpy(retstr, wword);
-
-  delete[] wword;
+bool WinApi::SetWindowTransparent(LONG hwnd, LONG trans)
+{
+	bool bret = false;
+
+	COLORREF crKey = NULL;
+	DWORD dwFlags = 0;
+	BYTE bAlpha = 0;
+	if (trans < 0) trans = 0;
+	if (trans > 255) trans = 255;
+	//...
+	/*typedef bool(__stdcall  *  mySetLayeredWindowAttributes)(
+			HWND hwnd,
+			COLORREF pcrKey,
+			BYTE pbAlpha,
+			DWORD pdwFlags);
+	mySetLayeredWindowAttributes obj_SetLayeredWindowAttributes = NULL;
+	HINSTANCE hlibrary;
+	hlibrary = LoadLibrary(_T("user32.dll"));
+	obj_SetLayeredWindowAttributes =
+	(mySetLayeredWindowAttributes)GetProcAddress(hlibrary,
+	"SetLayeredWindowAttributes");*/
+
+	SetWindowLong((HWND)hwnd, GWL_EXSTYLE, 0x80001);
+	bret = SetLayeredWindowAttributes((HWND)hwnd, crKey, trans, 2);
+
+	return bret;
+}
 
-  return bret;
+bool WinApi::SetClipboard(wchar_t* values)
+{
+	bool bret = false;
+	int n = ::WideCharToMultiByte(CP_ACP, 0, values, -1, NULL, 0, NULL, NULL);
+	char* chcontent = new char[n + 1];
+	memset(chcontent, 0, sizeof(char) * n + 1);
+	WideCharToMultiByte(CP_ACP, 0, values, -1, chcontent, n, NULL, NULL);
+
+	if (OpenClipboard(NULL))
+	{
+		//将剪贴板内容清空
+		EmptyClipboard();
+		//字节长度
+		int leng = strlen(chcontent) + 1;
+		//在堆上分配可移动的内存块,程序返回一个内存句柄
+		HANDLE hClip = GlobalAlloc(GHND | GMEM_SHARE, leng);
+		//定义指向字符型的指针变量
+		char* buff;
+		//对分配的内存块进行加锁,将内存块句柄转化成一个指针,并将相应的引用计数器加一
+		buff = (char*)GlobalLock(hClip);
+		//将用户输入的数据拷贝到指针变量中,实际上就是拷贝到分配的内存块中
+		memcpy(buff, chcontent, leng);
+		buff[leng - 1] = 0;
+		//数据写入完毕,进行解锁操作,并将引用计数器数字减一
+		GlobalUnlock(hClip);
+		//将存放有数据的内存块放入剪贴板的资源管理中
+		HANDLE help = SetClipboardData(CF_TEXT, hClip);
+		//关闭剪贴板,释放剪贴板资源的占用权
+		CloseClipboard();
+		// MessageBox(0,L"已将数据存入剪贴板",L"剪切扳",0);
+		if (help != NULL) {
+			bret = true;
+		}
+		else {
+			bret = false;
+		}
+	}
+	delete[] chcontent;
+	return bret;
 }
 
-long WinApi::SendString(HWND hwnd, const wstring &s) {
-  if (::IsWindow(hwnd)) {
-    auto p = s.data();
-    for (int i = 0; i < s.length(); ++i) {
-      ::PostMessageW(hwnd, WM_CHAR, p[i], 0);
-      ::Sleep(5);
-    }
-    return 1;
-  }
-  return 0;
+bool WinApi::GetClipboard(wchar_t* retstr) 
+{
+	bool bret = false;
+	HANDLE hClip;
+	char* chBuffer = NULL;
+	if (OpenClipboard(NULL)) {
+		//从剪贴板中取出一个内存的句柄
+		hClip = GetClipboardData(CF_TEXT);
+		//定义字符型指针变量用来保存内存块中的数据
+
+		//对内存块进行加锁,将内存句柄值转化为一个指针,并将内存块的引用计数器加一,内存中的数据也返回到指针型变量中
+		chBuffer = (char*)GlobalLock(hClip);
+
+		//将数据保存到字符型变量中
+		//将内存块的引用计数器减一
+		GlobalUnlock(hClip);
+		//关闭剪贴板,释放剪贴板资源的占用权
+		CloseClipboard();
+	}
+
+	DWORD num = MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, NULL, 0);
+	wchar_t* wword = new wchar_t[num + 1];          //动态的申请空间存字
+	memset(wword, 0, (num + 1) * sizeof(wchar_t));  //初始化动作
+	MultiByteToWideChar(CP_ACP, 0, chBuffer, -1, wword, num);
+
+	if (num < MAX_PATH * 4 - 1) wcscpy(retstr, wword);
+
+	delete[] wword;
+
+	return bret;
 }
 
-long WinApi::SendStringIme(HWND hwnd, const wstring &s) {
-  if (::IsWindow(hwnd)) {
-    auto p = s.data();
-    for (int i = 0; i < s.length(); ++i) {
-      ::PostMessage(hwnd, WM_IME_CHAR, p[i], 0);
-      ::Sleep(5);
-    }
-    return 1;
-  }
-  return 0;
+long WinApi::SendString(HWND hwnd, const wstring& s) 
+{
+	if (::IsWindow(hwnd)) {
+		auto p = s.data();
+		for (int i = 0; i < s.length(); ++i) {
+			::PostMessageW(hwnd, WM_CHAR, p[i], 0);
+			::Sleep(5);
+		}
+		return 1;
+	}
+	return 0;
 }
 
-long WinApi::RunApp(const wstring &cmd, long mode) {
-  std::unique_ptr<wchar_t> cmdptr(new wchar_t[cmd.length()]);
-  memcpy(cmdptr.get(), cmd.data(), cmd.length() * sizeof(wchar_t));
-  /*SECURITY_ATTRIBUTES SA;
-  SA.bInheritHandle = NULL;
-  SA.*/
-  STARTUPINFO si;
-  PROCESS_INFORMATION pi;
-  ZeroMemory(&si, sizeof(si));
-  ZeroMemory(&pi, sizeof(pi));
-  int bret;
-  wstring curr_dir;
-  if (mode == 1) {
-    // find
-    size_t pos;
-    pos = cmd.find(L".exe");
-    if (pos != wstring::npos && pos != 0) {
-      for (int i = pos - 1; i >= 1; --i) {
-        if (cmd[i] == L'\\' || cmd[i] == L'/') {
-          pos = i;
-          break;
-        }
-      }
-      if (pos > 0) {
-        curr_dir = cmd.substr(0, pos);
-      }
-    }
-    // setlog(curr_dir.c_str());
-  }
-  bret = ::CreateProcessW(
-      nullptr,       //// 应用程序名称
-      cmdptr.get(),  // 命令行字符串
-      NULL,          // 进程的安全属性
-      NULL,          // 线程的安全属性
-      false,         // 是否继承父进程的属性
-      0,             // 创建标志
-      nullptr,       // 指向新的环境块的指针
-      mode == 1 && !curr_dir.empty() ? curr_dir.c_str()
-                                     : nullptr,  // 指向当前目录名的指针
-      &si,                                       // 传递给新进程的信息
-      &pi                                        // 新进程返回的信息
-  );
-  if (bret) {
-    CloseHandle(pi.hProcess);
-    CloseHandle(pi.hThread);
-  }
-
-  return bret;
+long WinApi::SendStringIme(HWND hwnd, const wstring& s) 
+{
+	if (::IsWindow(hwnd)) {
+		auto p = s.data();
+		for (int i = 0; i < s.length(); ++i) {
+			::PostMessage(hwnd, WM_IME_CHAR, p[i], 0);
+			::Sleep(5);
+		}
+		return 1;
+	}
+	return 0;
 }
 
-HWND WinApi::GetTopWindowSp(HWND hwnd) {
-  HWND i = hwnd, temp;
+long WinApi::RunApp(const wstring& cmd, long mode)
+{
+	std::unique_ptr<wchar_t> cmdptr(new wchar_t[cmd.length()]);
+	memcpy(cmdptr.get(), cmd.data(), cmd.length() * sizeof(wchar_t));
+	/*SECURITY_ATTRIBUTES SA;
+	SA.bInheritHandle = NULL;
+	SA.*/
+	STARTUPINFO si;
+	PROCESS_INFORMATION pi;
+	ZeroMemory(&si, sizeof(si));
+	ZeroMemory(&pi, sizeof(pi));
+	int bret;
+	wstring curr_dir;
+	if (mode == 1) {
+		// find
+		size_t pos;
+		pos = cmd.find(L".exe");
+		if (pos != wstring::npos && pos != 0) {
+			for (int i = pos - 1; i >= 1; --i) {
+				if (cmd[i] == L'\\' || cmd[i] == L'/') {
+					pos = i;
+					break;
+				}
+			}
+			if (pos > 0) {
+				curr_dir = cmd.substr(0, pos);
+			}
+		}
+		// setlog(curr_dir.c_str());
+	}
+	bret = ::CreateProcessW(
+		nullptr,       //// 应用程序名称
+		cmdptr.get(),  // 命令行字符串
+		NULL,          // 进程的安全属性
+		NULL,          // 线程的安全属性
+		false,         // 是否继承父进程的属性
+		0,             // 创建标志
+		nullptr,       // 指向新的环境块的指针
+		mode == 1 && !curr_dir.empty() ? curr_dir.c_str()
+		: nullptr,  // 指向当前目录名的指针
+		&si,                                       // 传递给新进程的信息
+		&pi                                        // 新进程返回的信息
+	);
+	if (bret) {
+		CloseHandle(pi.hProcess);
+		CloseHandle(pi.hThread);
+	}
+
+	return bret;
+}
 
-  while (GetWindowLongA(i, GWL_STYLE) >= 0) {
-    temp = GetParent(i);
-    if (!temp) break;
-  }
-  return i;
+HWND WinApi::GetTopWindowSp(HWND hwnd) 
+{
+	HWND i = hwnd, temp;
+	while (GetWindowLongA(i, GWL_STYLE) >= 0) 
+	{
+		temp = GetParent(i);
+		if (!temp) break;
+	}
+
+	return i;
 }

+ 18 - 19
gm/gm/winapi/WinApi.h

@@ -1,58 +1,57 @@
 #pragma once
 #ifndef __WINAPI_H_
 #define __WINAPI_JH_
+
 #include "../core/optype.h"
 #undef FindWindow
 #undef FindWindowEx
+
 class WinApi
 {
 public:
 	WinApi(void);
 	~WinApi(void);
 
-
 public:
 	int retstringlen;
 	DWORD WindowVerion;
 	DWORD IsEuemprosuccess;
 	DWORD npid[MAX_PATH];
-	bool EnumWindow(HWND parent, const wchar_t *title, const wchar_t *class_name, LONG filter, wchar_t *retstring, const wchar_t  *process_name = NULL);
-	bool EnumWindowSuper(wchar_t *spec1, LONG flag1, LONG type1, wchar_t *spec2, LONG flag2, LONG type2, LONG sort, wchar_t *retstring = NULL);
-	bool EnumProcess(const wchar_t *name, wchar_t *retstring);
-	bool ClientToScreen(LONG hwnd, LONG &x, LONG &y);
-	long FindWindow(const wchar_t *class_name, const wchar_t*title);
-	long FindWindowEx(long parent, const wchar_t *class_name, const wchar_t*title);
-	bool FindWindowByProcess(const wchar_t *class_name, const wchar_t *titl, LONG &rethwnd, const wchar_t *process_name = NULL, DWORD Pid = 0);
-	bool GetClientRect(LONG hwnd, LONG &x, LONG &y, LONG &x1, LONG &y1);
-	bool GetClientSize(LONG hwnd, LONG &width, LONG &height);
-	bool GetMousePointWindow(LONG &rethwnd, LONG x = -1, LONG y = -1);
-	bool GetProcessInfo(LONG pid, wchar_t *retstring);
-	bool GetWindow(LONG hwnd, LONG flag, LONG &rethwnd);
+	bool EnumWindow(HWND parent, const wchar_t* title, const wchar_t* class_name, LONG filter, wchar_t* retstring, const wchar_t* process_name = NULL);
+	bool EnumWindowSuper(wchar_t* spec1, LONG flag1, LONG type1, wchar_t* spec2, LONG flag2, LONG type2, LONG sort, wchar_t* retstring = NULL);
+	bool EnumProcess(const wchar_t* name, wchar_t* retstring);
+	bool ClientToScreen(LONG hwnd, LONG& x, LONG& y);
+	long FindWindow(const wchar_t* class_name, const wchar_t* title);
+	long FindWindowEx(long parent, const wchar_t* class_name, const wchar_t* title);
+	bool FindWindowByProcess(const wchar_t* class_name, const wchar_t* titl, LONG& rethwnd, const wchar_t* process_name = NULL, DWORD Pid = 0);
+	bool GetClientRect(LONG hwnd, LONG& x, LONG& y, LONG& x1, LONG& y1);
+	bool GetClientSize(LONG hwnd, LONG& width, LONG& height);
+	bool GetMousePointWindow(LONG& rethwnd, LONG x = -1, LONG y = -1);
+	bool GetProcessInfo(LONG pid, wchar_t* retstring);
+	bool GetWindow(LONG hwnd, LONG flag, LONG& rethwnd);
 	bool GetProcesspath(DWORD ProcessID, wchar_t* process_path);
 	bool GetWindowState(LONG hwnd, LONG flag);
 	bool SendPaste(LONG hwnd);
 	bool SetWindowSize(LONG hwnd, LONG width, LONG hight, int type = 0);
 	bool SetWindowState(LONG hwnd, LONG flag, LONG rethwnd = 0);
 	bool SetWindowTransparent(LONG hwnd, LONG trans);
-	bool SetClipboard(wchar_t *values);
-	bool GetClipboard(wchar_t *retstr);
+	bool SetClipboard(wchar_t* values);
+	bool GetClipboard(wchar_t* retstr);
 	//2019.1
 	long SendString(HWND hwnd, const wstring& str);
 	long SendStringIme(HWND hwnd, const wstring& str);
 	//2019.3
 	long RunApp(const wstring& cmd, long mode);
 	static HWND GetTopWindowSp(HWND hwnd);
+
 private:
-	DWORD  FindChildWnd(HWND hchile, const wchar_t *title, const wchar_t *classname, wchar_t *retstring, bool isGW_OWNER = false, bool isVisible = false, const wchar_t  *process_name = NULL);
+	DWORD  FindChildWnd(HWND hchile, const wchar_t* title, const wchar_t* classname, wchar_t* retstring, bool isGW_OWNER = false, bool isVisible = false, const wchar_t* process_name = NULL);
 	BOOL   EnumProcessbyName(DWORD   dwPID, LPCWSTR   ExeName, LONG type = 0);
 	int GetProcessNumber();//获取CPU个数
 	// 时间格式转换
 	__int64 FileTimeToInt64(const FILETIME& time);
 	double get_cpu_usage(DWORD ProcessID);	 //获取指定进程CPU使用率
 	DWORD GetMemoryInfo(DWORD ProcessID);  //或者指定进程内存使用率
-
-
 };
 
-
 #endif

+ 4 - 5
gm/gm/winapi/query_api.cpp

@@ -2,21 +2,20 @@
 #include "core/optype.h"
 #include "query_api.h"
 
-
-void* query_api(const char* mod_name, const char* func_name) {
+void* query_api(const char* mod_name, const char* func_name) 
+{
 	auto hdll = ::GetModuleHandleA(mod_name);
 	if (!hdll) {
 		//_error_code = -1;
 		return NULL;
 	}
+
 	void* paddress = (void*)::GetProcAddress(hdll, func_name);
 	if (!paddress) {
 		//_error_code = -2;
 		return NULL;
 	}
+
 	//_error_code = 0;
 	return paddress;
-
 }
-
-

+ 1 - 3
gm/gm/winapi/query_api.h

@@ -1,5 +1,3 @@
 #pragma once
 
-void* query_api(const char* mod_name, const char* func_name);
-
-
+void* query_api(const char* mod_name, const char* func_name);

Some files were not shown because too many files changed in this diff