Browse Source

【模块名称】
GM模块;
【问题原因】
修改名称
【修改描述】

【测试结果】

sat23 3 years ago
parent
commit
7489b811a3
5 changed files with 4 additions and 1575 deletions
  1. 2 3
      gm/gm/gm.vcxproj
  2. 2 5
      gm/gm/gm.vcxproj.filters
  3. 0 1270
      gm/gm/libop.cpp
  4. 0 294
      gm/gm/libop.h
  5. 0 3
      gm/gm/winapi/MemoryEx.cpp

+ 2 - 3
gm/gm/gm.vcxproj

@@ -172,7 +172,7 @@
     <ClInclude Include="imageProc\ImageLoc.h" />
     <ClInclude Include="imageProc\ImageProc.h" />
     <ClInclude Include="imageProc\imageView.hpp" />
-    <ClInclude Include="libop.h" />
+    <ClInclude Include="gm.h" />
     <ClInclude Include="winapi\Injecter.h" />
     <ClInclude Include="winapi\MemoryEx.h" />
     <ClInclude Include="winapi\query_api.h" />
@@ -233,7 +233,7 @@
     <ClCompile Include="imageProc\ImageProc.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
     </ClCompile>
-    <ClCompile Include="libop.cpp">
+    <ClCompile Include="gm.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
     </ClCompile>
     <ClCompile Include="winapi\Injecter.cpp">
@@ -252,7 +252,6 @@
   <ItemGroup>
     <ClInclude Include="framework.h" />
     <ClInclude Include="Resource.h" />
-    <ClInclude Include="targetver.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="dllmain.cpp" />

+ 2 - 5
gm/gm/gm.vcxproj.filters

@@ -50,13 +50,10 @@
     <ClInclude Include="framework.h">
       <Filter>头文件</Filter>
     </ClInclude>
-    <ClInclude Include="targetver.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
     <ClInclude Include="Resource.h">
       <Filter>头文件</Filter>
     </ClInclude>
-    <ClInclude Include="libop.h">
+    <ClInclude Include="gm.h">
       <Filter>头文件</Filter>
     </ClInclude>
     <ClInclude Include="winapi\Injecter.h">
@@ -147,7 +144,7 @@
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="libop.cpp">
+    <ClCompile Include="gm.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
     <ClCompile Include="winapi\Injecter.cpp">

+ 0 - 1270
gm/gm/libop.cpp

@@ -1,1270 +0,0 @@
-// OpInterface.cpp: OpInterface 的实现
-#include "libop.h"
-#include "./core/optype.h"
-#include "./core/globalVar.h"
-#include "./core/helpfunc.h"
-#include "./core/opEnv.h"
-#include "./winapi/WinApi.h"
-#include "./background/opBackground.h"
-#include "./ImageProc/ImageProc.h"
-#include "./core/Cmder.h"
-#include "./winapi/Injecter.h"
-#include "./algorithm/AStar.hpp"
-#include "./winapi/MemoryEx.h"
-#include <fstream>
-#include <filesystem>
-#include <regex>
-
-#undef FindWindow
-#undef FindWindowEx
-#undef SetWindowText
-
-const int small_block_size = 10;
-
-libop::libop()
-{
-	_winapi = new WinApi;
-	_bkproc = new opBackground;
-	_image_proc = new ImageProc;
-
-	//初始化目录
-	wchar_t buff[256];
-	::GetCurrentDirectoryW(256, buff);
-	_curr_path = buff;
-	_image_proc->_curr_path = _curr_path;
-	//初始化键码表
-	_vkmap[L"back"] = VK_BACK;
-	_vkmap[L"ctrl"] = VK_CONTROL;
-	_vkmap[L"alt"] = 18;
-	_vkmap[L"shift"] = VK_SHIFT;
-	_vkmap[L"win"] = VK_LWIN;
-	_vkmap[L"space"] = L' ';
-	_vkmap[L"tab"] = VK_TAB;
-	_vkmap[L"esc"] = VK_CANCEL;
-	_vkmap[L"enter"] = L'\r';
-	_vkmap[L"up"] = VK_UP;
-	_vkmap[L"down"] = VK_DOWN;
-	_vkmap[L"left"] = VK_LEFT;
-	_vkmap[L"right"] = VK_RIGHT;
-	_vkmap[L"f1"] = VK_F1;
-	_vkmap[L"f2"] = VK_F2;
-	_vkmap[L"f3"] = VK_F3;
-	_vkmap[L"f4"] = VK_F4;
-	_vkmap[L"f5"] = VK_F5;
-	_vkmap[L"f6"] = VK_F6;
-	_vkmap[L"f7"] = VK_F7;
-	_vkmap[L"f8"] = VK_F8;
-	_vkmap[L"f9"] = VK_F9;
-	_vkmap[L"f10"] = VK_F10;
-	_vkmap[L"f11"] = VK_F11;
-	_vkmap[L"f12"] = VK_F12;
-
-	m_opPath = opEnv::getBasePath();
-}
-
-libop::~libop()
-{
-	delete _winapi;
-	delete _bkproc;
-	delete _image_proc;
-}
-
-std::wstring libop::Ver()
-{
-
-	//Tool::setlog("address=%d,str=%s", ver, ver);
-	return _T(OP_VERSION);
-}
-
-void libop::SetPath(const wchar_t* path, long* ret)
-{
-	wstring fpath = path;
-	replacew(fpath, L"/", L"\\");
-	if (fpath.find(L'\\') != -1 && ::PathFileExistsW(fpath.data()))
-	{
-		_curr_path = fpath;
-		_image_proc->_curr_path = _curr_path;
-		_bkproc->_curr_path = _curr_path;
-		*ret = 1;
-	}
-	else
-	{
-
-		if (!fpath.empty() && fpath[0] != L'\\')
-			fpath = _curr_path + L'\\' + fpath;
-		else
-			fpath = _curr_path + fpath;
-		if (::PathFileExistsW(fpath.data()))
-		{
-			_curr_path = path;
-			_image_proc->_curr_path = _curr_path;
-			_bkproc->_curr_path = _curr_path;
-			*ret = 1;
-		}
-		else
-			*ret = 0;
-	}
-}
-
-void libop::GetPath(std::wstring& path)
-{
-	path = _curr_path;
-}
-
-void libop::GetBasePath(std::wstring& path)
-{
-	path = opEnv::getBasePath();
-}
-
-void libop::GetID(long* ret)
-{
-	*ret = (long)this;
-}
-
-void libop::GetLastError(long* ret)
-{
-	*ret = ::GetLastError();
-}
-
-void libop::SetShowErrorMsg(long show_type, long* ret)
-{
-	opEnv::m_showErrorMsg = show_type;
-	*ret = 1;
-}
-
-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)
-{
-	auto proc = _ws2string(process_name);
-	auto dll = _ws2string(dll_name);
-	long hwnd;
-	FindWindowByProcess(process_name, L"", L"", &hwnd);
-	long pid;
-	GetWindowProcessId(hwnd, &pid);
-	*ret = 0;
-	if (Injecter::EnablePrivilege(TRUE))
-	{
-		long error_code = 0;
-		*ret = Injecter::InjectDll(pid, dll_name, error_code);
-	}
-	else
-	{
-		setlog("EnablePrivilege false erro_code=%08X ", ::GetLastError());
-	}
-}
-
-void libop::EnablePicCache(long enable, long* ret)
-{
-	_image_proc->_enable_cache = enable;
-	*ret = 1;
-}
-
-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)
-{
-	AStar as;
-	using Vec2i = AStar::Vec2i;
-	vector<Vec2i> walls;
-	vector<wstring> vstr;
-	Vec2i tp;
-	split(disable_points, vstr, L"|");
-	for (auto& it : vstr)
-	{
-		if (swscanf(it.c_str(), L"%d,%d", &tp.x, &tp.y) != 2)
-			break;
-		walls.push_back(tp);
-	}
-	list<Vec2i> paths;
-
-	as.set_map(mapWidth, mapHeight, walls);
-	as.findpath(beginX, beginY, endX, endY, paths);
-	wstring pathstr;
-	wchar_t buf[20];
-	for (auto it = paths.rbegin(); it != paths.rend(); ++it)
-	{
-		auto v = *it;
-		wsprintf(buf, L"%d,%d", v.x, v.y);
-		pathstr += buf;
-		pathstr.push_back(L'|');
-	}
-	if (!pathstr.empty())
-		pathstr.pop_back();
-}
-
-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 };
-	double old = 1e9;
-	long rx = -1, ry = -1;
-	std::wstring s = std::regex_replace(all_pos, std::wregex(L","), L" ");
-	p = s.data();
-	while (*p)
-	{
-		long x2, y2;
-		bool ok = false;
-		if (type == 1)
-		{
-
-			if (swscanf(p, L"%d %d", &x2, &y2) == 2)
-			{
-				ok = true;
-			}
-		}
-		else
-		{
-			if (swscanf(p, L"%s %d %d", buf, &x2, &y2) == 3)
-			{
-				ok = true;
-			}
-		}
-		if (ok)
-		{
-			double compareDis = (x - x2) * (x - x2) + (y - y2) * (y - y2);
-			if (compareDis < old)
-			{
-				rx = x2;
-				ry = y2;
-				old = compareDis;
-				wcscpy(rs, buf);
-			}
-		}
-		while (*p && *p != L'|')
-			++p;
-		if (*p)
-			++p;
-	}
-	if (rs[0])
-	{
-		wcscpy(buf, rs);
-		wsprintf(rs, L"%s,%d,%d", buf, rx, ry);
-	}
-	else if (type == 1 && rx != -1)
-	{
-		wsprintf(rs, L"%d,%d", rx, ry);
-	}
-	ret = rs;
-}
-
-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]);
-	memset(retstring.get(), 0, sizeof(wchar_t) * MAX_PATH * 200);
-	_winapi->EnumWindow((HWND)parent, title, class_name, filter, retstring.get());
-	//*retstr=_bstr_t(retstring);
-	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)
-{
-	// TODO: 在此添加实现代码
-	std::unique_ptr<wchar_t> retstr(new wchar_t[MAX_PATH * 200]);
-	memset(retstr.get(), 0, sizeof(wchar_t) * MAX_PATH * 200);
-	_winapi->EnumWindow((HWND)0, title, class_name, filter, retstr.get(), process_name);
-	//*retstring=_bstr_t(retstr);
-
-	retstring = retstr.get();
-}
-
-void libop::EnumProcess(const wchar_t* name, std::wstring& retstring)
-{
-	// TODO: 在此添加实现代码
-	std::unique_ptr<wchar_t> retstr(new wchar_t[MAX_PATH * 200]);
-	memset(retstr.get(), 0, sizeof(wchar_t) * MAX_PATH * 200);
-	_winapi->EnumProcess(name, retstr.get());
-	//*retstring=_bstr_t(retstr);
-	retstring = retstr.get();
-}
-
-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)
-{
-	// 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)
-{
-	// 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)
-{
-	// 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)
-{
-	// TODO: 在此添加实现代码
-	*rethwnd = _winapi->FindWindowEx(parent, class_name, title);
-}
-
-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)
-{
-	// TODO: 在此添加实现代码
-
-	*nret = _winapi->GetClientSize(hwnd, *width, *height);
-}
-
-void libop::GetForegroundFocus(long* rethwnd)
-{
-	// TODO: 在此添加实现代码
-	*rethwnd = (LONG)::GetFocus();
-}
-
-void libop::GetForegroundWindow(long* rethwnd)
-{
-	// TODO: 在此添加实现代码
-	*rethwnd = (LONG)::GetForegroundWindow();
-}
-
-void libop::GetMousePointWindow(long* rethwnd)
-{
-	// TODO: 在此添加实现代码
-	//::Sleep(2000);
-	_winapi->GetMousePointWindow(*rethwnd);
-}
-
-void libop::GetPointWindow(long x, long y, long* rethwnd)
-{
-	// TODO: 在此添加实现代码
-	_winapi->GetMousePointWindow(*rethwnd, x, y);
-}
-
-void libop::GetProcessInfo(long pid, std::wstring& retstring)
-{
-	// TODO: 在此添加实现代码
-
-	wchar_t retstr[MAX_PATH] = { 0 };
-	_winapi->GetProcessInfo(pid, retstr);
-	//* retstring=_bstr_t(retstr);
-
-	retstring = retstr;
-}
-
-void libop::GetSpecialWindow(long flag, long* rethwnd)
-{
-	// TODO: 在此添加实现代码
-	*rethwnd = 0;
-	if (flag == 0)
-		*rethwnd = (LONG)GetDesktopWindow();
-	else if (flag == 1)
-	{
-		*rethwnd = (LONG)::FindWindowW(L"Shell_TrayWnd", NULL);
-	}
-}
-
-void libop::GetWindow(long hwnd, long flag, long* nret)
-{
-	// TODO: 在此添加实现代码
-	_winapi->GetWindow(hwnd, flag, *nret);
-}
-
-void libop::GetWindowClass(long hwnd, std::wstring& retstring)
-{
-	// TODO: 在此添加实现代码
-	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)
-{
-	// TODO: 在此添加实现代码
-	DWORD pid = 0;
-	::GetWindowThreadProcessId((HWND)hwnd, &pid);
-	*nretpid = pid;
-}
-
-void libop::GetWindowProcessPath(long hwnd, std::wstring& retstring)
-{
-	// TODO: 在此添加实现代码
-	DWORD pid = 0;
-	::GetWindowThreadProcessId((HWND)hwnd, &pid);
-	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)
-{
-	// TODO: 在此添加实现代码
-	RECT winrect;
-	*nret = ::GetWindowRect((HWND)hwnd, &winrect);
-	*x1 = winrect.left;
-	*y1 = winrect.top;
-	*x2 = winrect.right;
-	*y2 = winrect.bottom;
-}
-
-void libop::GetWindowState(long hwnd, long flag, long* rethwnd)
-{
-	// TODO: 在此添加实现代码
-	*rethwnd = _winapi->GetWindowState(hwnd, flag);
-}
-
-void libop::GetWindowTitle(long hwnd, std::wstring& rettitle)
-{
-	// TODO: 在此添加实现代码
-	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)
-{
-	// TODO: 在此添加实现代码
-	RECT winrect;
-	::GetWindowRect((HWND)hwnd, &winrect);
-	int width = winrect.right - winrect.left;
-	int hight = winrect.bottom - winrect.top;
-	*nret = ::MoveWindow((HWND)hwnd, x, y, width, hight, false);
-}
-
-void libop::ScreenToClient(long hwnd, long* x, long* y, long* nret)
-{
-	// TODO: 在此添加实现代码
-
-	POINT point;
-	*nret = ::ScreenToClient((HWND)hwnd, &point);
-	*x = point.x;
-	*y = point.y;
-}
-
-void libop::SendPaste(long hwnd, long* nret)
-{
-	// TODO: 在此添加实现代码
-	*nret = _winapi->SendPaste(hwnd);
-}
-
-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)
-{
-	// TODO: 在此添加实现代码
-	*nret = _winapi->SetWindowState(hwnd, flag);
-}
-
-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)
-{
-	// TODO: 在此添加实现代码
-	//*nret=gWindowObj.TSSetWindowState(hwnd,flag);
-	*nret = ::SetWindowTextW((HWND)hwnd, title);
-}
-
-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)
-{
-	*ret = _winapi->SendString((HWND)hwnd, str);
-}
-
-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)
-{
-	*ret = _winapi->RunApp(cmdline, mode);
-}
-
-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)
-{
-	auto strcmd = _ws2string(cmd);
-	Cmder cd;
-	auto str = cd.GetCmdStr(strcmd, millseconds <= 0 ? 5 : millseconds);
-	retstr = _s2wstring(str);
-}
-
-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();
-	*ret = _bkproc->BindWindow(hwnd, display, mouse, keypad, mode);
-	if (*ret == 1)
-	{
-		//_image_proc->set_offset(_bkproc->_pbkdisplay->_client_x, _bkproc->_pbkdisplay->_client_y);
-	}
-}
-
-void libop::UnBindWindow(long* ret)
-{
-	*ret = _bkproc->UnBindWindow();
-}
-
-void libop::GetCursorPos(long* x, long* y, long* ret)
-{
-
-	*ret = _bkproc->_bkmouse->GetCursorPos(*x, *y);
-}
-
-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)
-{
-	*ret = _bkproc->_bkmouse->MoveTo(x, y);
-}
-
-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)
-{
-	*ret = _bkproc->_bkmouse->LeftClick();
-}
-
-void libop::LeftDoubleClick(long* ret)
-{
-	*ret = _bkproc->_bkmouse->LeftDoubleClick();
-}
-
-void libop::LeftDown(long* ret)
-{
-	*ret = _bkproc->_bkmouse->LeftDown();
-}
-
-void libop::LeftUp(long* ret)
-{
-	*ret = _bkproc->_bkmouse->LeftUp();
-}
-
-void libop::MiddleClick(long* ret)
-{
-	*ret = _bkproc->_bkmouse->MiddleClick();
-}
-
-void libop::MiddleDown(long* ret)
-{
-	*ret = _bkproc->_bkmouse->MiddleDown();
-}
-
-void libop::MiddleUp(long* ret)
-{
-	*ret = _bkproc->_bkmouse->MiddleUp();
-}
-
-void libop::RightClick(long* ret)
-{
-	*ret = _bkproc->_bkmouse->RightClick();
-}
-
-void libop::RightDown(long* ret)
-{
-	*ret = _bkproc->_bkmouse->RightDown();
-}
-
-void libop::RightUp(long* ret)
-{
-	*ret = _bkproc->_bkmouse->RightUp();
-}
-
-void libop::WheelDown(long* ret)
-{
-	*ret = _bkproc->_bkmouse->WheelDown();
-}
-
-void libop::WheelUp(long* ret)
-{
-	*ret = _bkproc->_bkmouse->WheelUp();
-}
-
-void libop::GetKeyState(long vk_code, long* ret)
-{
-	*ret = _bkproc->_keypad->GetKeyState(vk_code);
-}
-
-void libop::KeyDown(long vk_code, long* ret)
-{
-	*ret = _bkproc->_keypad->KeyDown(vk_code);
-}
-
-void libop::KeyDownChar(const wchar_t* vk_code, long* ret)
-{
-	auto nlen = wcslen(vk_code);
-	*ret = 0;
-	if (nlen > 0)
-	{
-		wstring s = vk_code;
-		wstring2lower(s);
-		long vk = _vkmap.count(s) ? _vkmap[s] : vk_code[0];
-		*ret = _bkproc->_keypad->KeyDown(vk);
-	}
-}
-
-void libop::KeyUp(long vk_code, long* ret)
-{
-	*ret = _bkproc->_keypad->KeyUp(vk_code);
-}
-
-void libop::KeyUpChar(const wchar_t* vk_code, long* ret)
-{
-	auto nlen = wcslen(vk_code);
-	*ret = 0;
-	if (nlen > 0)
-	{
-		wstring s = vk_code;
-		wstring2lower(s);
-		long vk = _vkmap.count(s) ? _vkmap[s] : vk_code[0];
-		*ret = _bkproc->_keypad->KeyUp(vk);
-	}
-}
-
-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)
-{
-
-	*ret = _bkproc->_keypad->KeyPress(vk_code);
-}
-
-void libop::KeyPressChar(const wchar_t* vk_code, long* ret)
-{
-	auto nlen = wcslen(vk_code);
-	*ret = 0;
-	if (nlen > 0)
-	{
-		//setlog(vk_code);
-		wstring s = vk_code;
-		wstring2lower(s);
-		long vk = _vkmap.count(s) ? _vkmap[s] : vk_code[0];
-		*ret = _bkproc->_keypad->KeyPress(vk);
-	}
-}
-
-//抓取指定区域(x1, y1, x2, y2)的图像, 保存为file
-void libop::Capture(long x1, long y1, long x2, long y2, const wchar_t* file_name, long* ret)
-{
-
-	*ret = 0;
-
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-
-			*ret = _image_proc->Capture(file_name);
-		}
-	}
-}
-
-//比较指定坐标点(x,y)的颜色
-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;
-	*ret = 0;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x, y, tx, ty))
-	{
-		if (!_bkproc->requestCapture(x, y, small_block_size, small_block_size, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x, y);
-			*ret = _image_proc->CmpColor(x, y, color, sim);
-		}
-	}
-}
-
-//查找指定区域内的颜色
-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;
-	*x = *y = -1;
-
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			*ret = _image_proc->FindColor(color, sim, dir, *x, *y);
-		}
-	}
-}
-
-//查找指定区域内的所有颜色
-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();
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_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)
-{
-
-	*ret = 0;
-	*x = *y = -1;
-
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			*ret = _image_proc->FindMultiColor(first_color, offset_color, sim, dir, *x, *y);
-		}
-
-		/*if (*ret) {
-			rx += x1; ry += y1;
-			rx -= _bkproc->_pbkdisplay->_client_x;
-			ry -= _bkproc->_pbkdisplay->_client_y;
-		}*/
-	}
-}
-
-//根据指定的多点查找所有颜色坐标
-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))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->FindMultiColorEx(first_color, offset_color, sim, dir, retstr);
-		}
-	}
-	//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)
-{
-
-	*ret = 0;
-	*x = *y = -1;
-
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			*ret = _image_proc->FindPic(files, delta_color, sim, 0, *x, *y);
-		}
-
-		/*if (*ret) {
-			rx += x1; ry += y1;
-			rx -= _bkproc->_pbkdisplay->_client_x;
-			ry -= _bkproc->_pbkdisplay->_client_y;
-		}*/
-	}
-}
-
-//查找多个图片
-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;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->FindPicEx(files, delta_color, sim, dir, retstr);
-		}
-	}
-	//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)
-{
-	//wstring str;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->FindPicEx(files, delta_color, sim, dir, retstr, false);
-		}
-	}
-	//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)
-{
-	*ret = 0;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			*ret = _image_proc->FindColorBlock(color, sim, count, height, width, *x, *y);
-		}
-	}
-}
-
-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))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->FindColorBlockEx(color, sim, count, height, width, retstr);
-		}
-	}
-}
-
-//获取(x,y)的颜色
-void libop::GetColor(long x, long y, std::wstring& ret)
-{
-	color_t cr;
-	auto tx = x + small_block_size, ty = y + small_block_size;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x, y, tx, ty))
-	{
-		if (_bkproc->requestCapture(x, y, small_block_size, small_block_size, _image_proc->_src))
-		{
-			_image_proc->set_offset(x, y);
-			cr = _image_proc->_src.at<color_t>(0, 0);
-		}
-		else
-		{
-			setlog("error requestCapture");
-		}
-	}
-	else
-	{
-		//setlog("")
-	}
-
-	ret = cr.towstr();
-}
-
-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)
-{
-	*ret = _image_proc->LoadPic(file_name);
-}
-
-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)
-{
-	*ret = _image_proc->LoadMemPic(file_name, data, size);
-}
-
-void libop::GetScreenData(long x1, long y1, long x2, long y2, void** data, long* ret)
-{
-	*data = nullptr;
-	*ret = 0;
-	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))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_screenData.resize(img.size() * 4);
-			//memcpy(_screenData.data(), img.pdata, img.size()*4);
-			for (int i = 0; i < img.height; i++)
-			{
-				memcpy(_screenData.data() + i * img.width * 4, img.ptr<char>(img.height - 1 - i), img.width * 4);
-			}
-			*data = _screenData.data();
-			*ret = 1;
-		}
-	}
-}
-
-void libop::GetScreenDataBmp(long x1, long y1, long x2, long y2, void** data, long* size, long* ret)
-{
-	*data = 0;
-	*ret = 0;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("rerror requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			auto& img = _image_proc->_src;
-
-			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;
-			bfh.bfSize = bfh.bfOffBits + img.width * img.height * 4;
-			bfh.bfType = static_cast<WORD>(0x4d42);
-
-			bih.biBitCount = 32; //每个像素字节大小
-			bih.biCompression = BI_RGB;
-			//bih.biHeight = -img.height;//高度 反
-			bih.biHeight = img.height; //高度
-			bih.biPlanes = 1;
-			bih.biSize = sizeof(BITMAPINFOHEADER);
-			bih.biSizeImage = img.width * 4 * img.height; //图像数据大小
-			bih.biWidth = img.width;					  //宽度
-
-			_screenDataBmp.resize(bfh.bfSize);
-			/*	std::ofstream f;
-		f.open("xx.bmp",std::ios::binary);
-		if (f) {
-			f.write((char*)&bfh, sizeof(bfh));
-			f.write((char*)&bih, sizeof(bih));
-			f.write((char*)img.pdata, img.size() * 4);
-		}
-
-		f.close();*/
-			auto dst = _screenDataBmp.data();
-
-			memcpy(dst, &bfh, sizeof(bfh));
-			memcpy(dst + sizeof(bfh), &bih, sizeof(bih));
-			dst += sizeof(bfh) + sizeof(bih);
-			for (int i = 0; i < img.height; i++)
-			{
-				memcpy(dst + i * img.width * 4, img.ptr<char>(img.height - 1 - i), img.width * 4);
-			}
-			//memcpy(dst + sizeof(bfh)+sizeof(bih), img.pdata, img.size()*4);
-			*data = _screenDataBmp.data();
-			*size = bfh.bfSize;
-			*ret = 1;
-		}
-	}
-}
-
-void libop::GetScreenFrameInfo(long* frame_id, long* time)
-{
-	FrameInfo info = {};
-	if (_bkproc->IsBind())
-	{
-		_bkproc->_pbkdisplay->getFrameInfo(info);
-	}
-	*frame_id = info.frameId;
-	*time = info.time;
-}
-
-void libop::MatchPicName(const wchar_t* pic_name, std::wstring& retstr)
-{
-	retstr.clear();
-	std::wstring s(pic_name);
-	if (s.find(L'/') != s.npos || s.find(L'\\') != s.npos)
-	{
-		setlog("invalid pic_name");
-	}
-
-	s = std::regex_replace(s, std::wregex(L"(\\.|\\(|\\)|\\[|\\]|\\{|\\})"), L"\\$1");
-	/*s = std::regex_replace(s, std::wregex(L"\\("), L"\\(");
-	s = std::regex_replace(s, std::wregex(L"\\)"), L"\\)");
-	s = std::regex_replace(s, std::wregex(L"\\["), L"\\[");
-	s = std::regex_replace(s, std::wregex(L"\\]"), L"\\]");*/
-	s = std::regex_replace(s, std::wregex(L"\\*"), L".*?");
-	s = std::regex_replace(s, std::wregex(L"\\?"), L".?");
-
-	//setlog(s.data());
-	namespace fs = std::filesystem;
-	fs::path path(_curr_path);
-	if (fs::exists(path))
-	{
-		fs::directory_iterator iter(path);
-		std::wstring tmp;
-		std::wregex e(s);
-		for (auto& it : iter)
-		{
-			if (it.status().type() == fs::file_type::regular)
-			{
-				tmp = it.path().filename();
-				try
-				{
-					if (std::regex_match(tmp, e))
-					{
-						retstr += tmp;
-						retstr += L"|";
-					}
-				}
-				catch (...)
-				{
-					setlog("exception!");
-				}
-			}
-		}
-		if (!retstr.empty() && retstr.back() == L'|')
-			retstr.pop_back();
-	}
-}
-
-//设置字库文件
-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)
-{
-	*ret = _image_proc->SetMemDict(idx, (void*)data, size);
-}
-
-//使用哪个字库文件进行识别
-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)
-{
-	wstring str;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->OCR(color, sim, str);
-		}
-	}
-	retstr = str;
-}
-
-//回识别到的字符串,以及每个字符的坐标.
-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))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->OcrEx(color, sim, str);
-		}
-	}
-	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)
-{
-	wstring str;
-	*retx = *rety = -1;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			*ret = _image_proc->FindStr(strs, color, sim, *retx, *rety);
-		}
-	}
-}
-
-//返回符合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)
-{
-	wstring str;
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->FindStrEx(strs, color, sim, str);
-		}
-	}
-	retstr = str;
-}
-
-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))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->OcrAuto(sim, str);
-		}
-	}
-	retstr = str;
-}
-
-//从文件中识别图片
-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)
-{
-	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)
-{
-	if (_bkproc->check_bind() && _bkproc->RectConvert(x1, y1, x2, y2))
-	{
-		if (!_bkproc->requestCapture(x1, y1, x2 - x1, y2 - y1, _image_proc->_src))
-		{
-			setlog("error requestCapture");
-		}
-		else
-		{
-			_image_proc->set_offset(x1, y1);
-			_image_proc->FindLine(color, sim, retstr);
-		}
-	}
-}
-
-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)
-{
-	MemoryEx mem;
-	retstr = mem.ReadData((HWND)hwnd, address, size);
-}

+ 0 - 294
gm/gm/libop.h

@@ -1,294 +0,0 @@
-// libop的声明
-/*
-所有op的开放接口都从此cpp类衍生而出
-*/
-#pragma once
-
-#include <string>
-#include<map>
-#include<vector>
-//forward declare
-class WinApi;
-class opBackground;
-class ImageProc;
-
-using bytearray = std::vector<unsigned char>;
-#ifdef U_STATIC_IMPLEMENTATION
-#define OP_API
-#else
-#ifndef OP_API 
-#if defined(OP_EXPORTS)
-#define OP_API __declspec(dllexport)
-#else
-#define OP_API __declspec(dllimport)
-#endif
-#endif
-#endif
-// libop
-#undef FindWindow
-#undef FindWindowEx
-#undef SetWindowText
-
-class OP_API libop 
-{
-public:
-	libop();
-	~libop();
-	//复制构造
-	libop(libop const&) = delete;
-	libop& operator=(libop const rhs) = delete;
-private:
-
-	//一些共用变量
-
-	//1. Windows API
-	WinApi* _winapi;
-	// background module
-	opBackground* _bkproc;
-	//image process
-	ImageProc* _image_proc;
-	// work path
-	std::wstring _curr_path;
-
-	std::map<std::wstring, long> _vkmap;
-	bytearray _screenData;
-	bytearray _screenDataBmp;
-	std::wstring m_opPath;
-public:
-	//---------------基本设置/属性-------------------
-
-	//1.版本号Version
-	std::wstring Ver();
-	//设置目录
-	void SetPath(const wchar_t* path, long* ret);
-	//获取目录
-	void GetPath(std::wstring& ret);
-	//获取插件目录
-	void GetBasePath(std::wstring& ret);
-	//返回当前对象的ID值,这个值对于每个对象是唯一存在的。可以用来判定两个对象是否一致
-	void GetID(long* ret);
-	//
-	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 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 FindNearestPos(const wchar_t* all_pos, long type, long x, long y, std::wstring& ret);
-	//--------------------windows api------------------------------
-	//根据指定条件,枚举系统中符合条件的窗口
-	void EnumWindow(long parent, const wchar_t* title, const wchar_t* class_name, long filter, std::wstring& ret);
-	//根据指定进程以及其它条件,枚举系统中符合条件的窗口
-	void EnumWindowByProcess(const wchar_t* process_name, const wchar_t* title, const wchar_t* class_name, long filter, std::wstring& ret);
-	//根据指定进程名,枚举系统中符合条件的进程PID
-	void EnumProcess(const wchar_t* name, std::wstring& ret);
-	//把窗口坐标转换为屏幕坐标
-	void ClientToScreen(long ClientToScreen, long* x, long* y, long* bret);
-	//查找符合类名或者标题名的顶层可见窗口
-	void FindWindow(const wchar_t* class_name, const wchar_t* title, long* ret);
-	//根据指定的进程名字,来查找可见窗口
-	void FindWindowByProcess(const wchar_t* process_name, const wchar_t* class_name, const wchar_t* title, long* ret);
-	//根据指定的进程Id,来查找可见窗口
-	void FindWindowByProcessId(long process_id, const wchar_t* class_name, const wchar_t* title, long* ret);
-	//查找符合类名或者标题名的顶层可见窗口,如果指定了parent,则在parent的第一层子窗口中查找
-	void FindWindowEx(long parent, const wchar_t* class_name, const wchar_t* title, long* ret);
-	//获取窗口客户区域在屏幕上的位置
-	void GetClientRect(long hwnd, long* x1, long* y1, long* x2, long* y2, long* ret);
-	//获取窗口客户区域的宽度和高度
-	void GetClientSize(long hwnd, long* width, long* height, long* ret);
-	//获取顶层活动窗口中具有输入焦点的窗口句柄
-	void GetForegroundFocus(long* ret);
-	//获取顶层活动窗口,可以获取到按键自带插件无法获取到的句柄
-	void GetForegroundWindow(long* ret);
-	//获取鼠标指向的可见窗口句柄
-	void GetMousePointWindow(long* ret);
-	//获取给定坐标的可见窗口句柄
-	void GetPointWindow(long x, long y, long* ret);
-	//根据指定的pid获取进程详细信息
-	void GetProcessInfo(long pid, std::wstring& ret);
-	//获取特殊窗口
-	void GetSpecialWindow(long flag, long* ret);
-	//获取给定窗口相关的窗口句柄
-	void GetWindow(long hwnd, long flag, long* ret);
-	//获取窗口的类名
-	void GetWindowClass(long hwnd, std::wstring& ret);
-	//获取指定窗口所在的进程ID
-	void GetWindowProcessId(long hwnd, long* ret);
-	//获取指定窗口所在的进程的exe文件全路径
-	void GetWindowProcessPath(long hwnd, std::wstring& ret);
-	//获取窗口在屏幕上的位置
-	void GetWindowRect(long hwnd, long* x1, long* y1, long* x2, long* y2, long* ret);
-	//获取指定窗口的一些属性
-	void GetWindowState(long hwnd, long flag, long* ret);
-	//获取窗口的标题
-	void GetWindowTitle(long hwnd, std::wstring& rettitle);
-	//移动指定窗口到指定位置
-	void MoveWindow(long hwnd, long x, long y, long* ret);
-	//把屏幕坐标转换为窗口坐标
-	void ScreenToClient(long hwnd, long* x, long* y, long* ret);
-	//向指定窗口发送粘贴命令
-	void SendPaste(long hwnd, long* ret);
-	//设置窗口客户区域的宽度和高度
-	void SetClientSize(long hwnd, long width, long hight, long* ret);
-	//设置窗口的状态
-	void SetWindowState(long hwnd, long flag, long* ret);
-	//设置窗口的大小
-	void SetWindowSize(long hwnd, long width, long height, long* ret);
-	//设置窗口的标题
-	void SetWindowText(long hwnd, const wchar_t* title, long* ret);
-	//设置窗口的透明度
-	void SetWindowTransparent(long hwnd, long trans, long* ret);
-	//向指定窗口发送文本数据
-	void SendString(long hwnd, const wchar_t* str, long* ret);
-	//向指定窗口发送文本数据-输入法
-	void SendStringIme(long hwnd, const wchar_t* str, long* ret);
-	//运行可执行文件,可指定模式
-	void RunApp(const wchar_t* cmdline, long mode, long* ret);
-	//运行可执行文件,可指定显示模式
-	void WinExec(const wchar_t* cmdline, long cmdshow, long* ret);
-
-	//运行命令行并返回结果
-	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 UnBindWindow(long* ret);
-	//--------------------mouse & keyboard------------------
-	//获取鼠标位置.
-	void GetCursorPos(long* x, long* y, long* ret);
-	//鼠标相对于上次的位置移动rx,ry.
-	void MoveR(long x, long y, long* ret);
-	//把鼠标移动到目的点(x,y)
-	void MoveTo(long x, long y, long* ret);
-	//把鼠标移动到目的范围内的任意一点
-	void MoveToEx(long x, long y, long w, long h, long* ret);
-	//按下鼠标左键
-	void LeftClick(long* ret);
-	//双击鼠标左键
-	void LeftDoubleClick(long* ret);
-	//按住鼠标左键
-	void LeftDown(long* ret);
-	//弹起鼠标左键
-	void LeftUp(long* ret);
-	//按下鼠标中键
-	void MiddleClick(long* ret);
-	//按住鼠标中键
-	void MiddleDown(long* ret);
-	//弹起鼠标中键
-	void MiddleUp(long* ret);
-	//按下鼠标右键
-	void RightClick(long* ret);
-	//按住鼠标右键
-	void RightDown(long* ret);
-	//弹起鼠标右键
-	void RightUp(long* ret);
-	//滚轮向下滚
-	void WheelDown(long* ret);
-	//滚轮向上滚
-	void WheelUp(long* ret);
-	//获取指定的按键状态.(前台信息,不是后台)
-	void GetKeyState(long vk_code, long* ret);
-	//按住指定的虚拟键码
-	void KeyDown(long vk_code, long* ret);
-	//按住指定的虚拟键码
-	void KeyDownChar(const wchar_t* vk_code, long* ret);
-	//弹起来虚拟键vk_code
-	void KeyUp(long vk_code, long* ret);
-	//弹起来虚拟键vk_code
-	void KeyUpChar(const wchar_t* vk_code, long* ret);
-	//等待指定的按键按下 (前台,不是后台)
-	void WaitKey(long vk_code, long time_out, long* ret);
-	//发送字符串
-	//long SendString(long HWND)
-	//弹起来虚拟键vk_code
-	void KeyPress(long vk_code, long* ret);
-	void KeyPressChar(const wchar_t* vk_code, long* ret);
-
-	//--------------------image and color-----------------------
-	//抓取指定区域(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 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 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 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);
-	//
-	//这个函数可以查找多个图片, 并且返回所有找到的图像的坐标.此函数同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);
-	//查找指定区域内的所有颜色块, 颜色格式"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);
-	//获取(x,y)的颜色
-	void GetColor(long x, long y, std::wstring& ret);
-	//
-	//设置图像输入方式,默认窗口截图
-	void SetDisplayInput(const wchar_t* mode, long* ret);
-
-	void LoadPic(const wchar_t* file_name, long* ret);
-
-	void FreePic(const wchar_t* file_name, 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 GetScreenDataBmp(long x1, long y1, long x2, long y2, void** data, long* size, long* ret);
-	//
-	void GetScreenFrameInfo(long* frame_id, long* time);
-	//
-	void MatchPicName(const wchar_t* pic_name, std::wstring& retstr);
-	//----------------------ocr-------------------------
-	//设置字库文件
-	void SetDict(long idx, const wchar_t* file_name, long* ret);
-	//设置内存字库文件
-	void SetMemDict(long idx, const wchar_t* data, long size, 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 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);
-	//返回符合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);
-	//识别屏幕范围(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 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);
-};
-
-
-

+ 0 - 3
gm/gm/winapi/MemoryEx.cpp

@@ -77,14 +77,11 @@ int stringcompute(const wchar_t* s)
 				push(os, *s);
 				s++;
 			}
-
-
 		}
 		else {
 			num.push_back(*s);
 			s++;
 		}
-
 	}
 
 	return ns.back();