
// GameAssistDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "GameAssist.h"
#include "GameAssistDlg.h"
//#include "VideoDXGICaptor.h"
#include "MouseAssist.h"
#include "CAction.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// 用于应用程序“关于”菜单项的 CAboutDlg 对话框

VOID DebugLog(CHAR* pszStr, ...)
{
	char szData[MAX_PATH] = { 0 };
	_stprintf_s(szData, _T("%s %s "), _T("[GameAssist] "), CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")).GetString());
	int len = strlen(szData);
	va_list args;
	va_start(args, pszStr);
	_vsnprintf_s(szData + len, MAX_PATH - len, MAX_PATH - len, pszStr, args);
	va_end(args);
	strcat_s(szData, "\n");
	OutputDebugStringA(szData);
}

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

	// 对话框数据
	enum { IDD = IDD_ABOUTBOX };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

// 实现
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CGameAssistDlg 对话框




CGameAssistDlg::CGameAssistDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CGameAssistDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CGameAssistDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_CHECK1, m_cbSummoner);
	DDX_Control(pDX, IDC_CHECK2, m_cbZJ);
	DDX_Control(pDX, IDC_CHECK3, m_cbZJ2);
	DDX_Control(pDX, IDC_CHECK6, m_cbAggressiveSkill);
	DDX_Control(pDX, IDC_COMBO1, m_cbGameRole);
	DDX_Control(pDX, IDC_COMBO2, m_cbZYNPC);
	DDX_Control(pDX, IDC_COMBO_SKILL_LIST, m_cb_skill_list);
}

BEGIN_MESSAGE_MAP(CGameAssistDlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(BTN_OPENGAME, &CGameAssistDlg::OnBnClickedOpengame)
	ON_BN_CLICKED(IDC_BUTTON2, &CGameAssistDlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &CGameAssistDlg::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON4, &CGameAssistDlg::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &CGameAssistDlg::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, &CGameAssistDlg::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON7, &CGameAssistDlg::OnBnClickedButton7)
	ON_BN_CLICKED(IDC_BUTTON8, &CGameAssistDlg::OnBnClickedButton8)
	ON_BN_CLICKED(IDC_BUTTON9, &CGameAssistDlg::OnBnClickedButton9)
	ON_BN_CLICKED(IDC_BUTTON10, &CGameAssistDlg::OnBnClickedButton10)
	ON_BN_CLICKED(IDC_BUTTON11, &CGameAssistDlg::OnBnClickedButton11)
	ON_BN_CLICKED(IDC_BUTTON12, &CGameAssistDlg::OnBnClickedButton12)
	ON_BN_CLICKED(IDC_BUTTON13, &CGameAssistDlg::OnBnClickedButton13)
	ON_BN_CLICKED(IDC_BUTTON14, &CGameAssistDlg::OnBnClickedButton14)
END_MESSAGE_MAP()


// CGameAssistDlg 消息处理程序

BOOL CGameAssistDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 将“关于...”菜单项添加到系统菜单中。

	// IDM_ABOUTBOX 必须在系统命令范围内。
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		BOOL bNameValid;
		CString strAboutMenu;
		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
		ASSERT(bNameValid);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// 设置此对话框的图标。当应用程序主窗口不是对话框时，框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	GameGlobal::Init();

	int nIndex = 0;
	for each (auto it in GameAssist::g_mapZYNPC)
	{
		m_cbZYNPC.InsertString(nIndex++, it.first.c_str());
	}
	m_cbZYNPC.SetCurSel(0);

	OnBnClickedButton11();
	InitSkillList();

	SetDlgItemInt(IDC_EDIT7, 100);

	return TRUE;  // 除非将焦点设置到控件，否则返回 TRUE
}

void CGameAssistDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// 如果向对话框添加最小化按钮，则需要下面的代码
//  来绘制该图标。对于使用文档/视图模型的 MFC 应用程序，
//  这将由框架自动完成。

void CGameAssistDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // 用于绘制的设备上下文

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// 使图标在工作区矩形中居中
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// 绘制图标
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR CGameAssistDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}


HWND CGameAssistDlg::GetCurGameWnd()
{
	int nCurSel = m_cbGameRole.GetCurSel();
	if (nCurSel == CB_ERR)
		return NULL;

	GameAssist::GameWndInfo* pInfo = (GameAssist::GameWndInfo*)m_cbGameRole.GetItemDataPtr(nCurSel);
	return pInfo->hWnd;
}

GameAssist::GameWndInfo* CGameAssistDlg::GetCurGameInfo()
{
	int nCurSel = m_cbGameRole.GetCurSel();
	if (nCurSel == CB_ERR)
		return NULL;

	return (GameAssist::GameWndInfo*)m_cbGameRole.GetItemDataPtr(nCurSel);
}

void CGameAssistDlg::InitSkillList()
{
	m_cb_skill_list.AddString("F1");
	m_cb_skill_list.AddString("F2");
	m_cb_skill_list.AddString("F3");
	m_cb_skill_list.AddString("F4");
	m_cb_skill_list.AddString("F5");
	m_cb_skill_list.AddString("F6");
	m_cb_skill_list.AddString("F7");
	m_cb_skill_list.AddString("F8");
	m_cb_skill_list.SetCurSel(7);
}

void CGameAssistDlg::OnBnClickedOpengame() // 打开游戏;
{
	// TODO: 在此添加控件通知处理程序代码
	if (!PathFileExists(GameGlobal::g_szGameApp))
	{
		MessageBox(_T("游戏程序不存在"), _T("温馨提示"));
		return;
	}

	// 设置辅助程序工作目录为游戏目录;
	//SetCurrentDirectory(_T("E:\\dhsh\\shdata\\"));
	SetCurrentDirectory(_T("D:\\tools\\dhsh\\shdata\\"));
#if 1
	ShellExecute(NULL, "open", GameGlobal::g_szGameApp, NULL, NULL, SW_SHOWNORMAL);//SW_HIDE无用,因为会自动结;
	Sleep(500); // Main.exe设置了陷阱(自己再开启了一个进程，结束上一个进程),需要等5秒;
#else
	SHELLEXECUTEINFO stuExecInfo = { 0 };
	DWORD dwExitCode = STILL_ACTIVE;
	//CString strCommandLine = _T("open");
	stuExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	stuExecInfo.lpFile = GameGlobal::g_szGamePath;
	stuExecInfo.lpParameters = "open";
	stuExecInfo.nShow = SW_SHOWNORMAL;
	stuExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;

	if (!ShellExecuteEx(&stuExecInfo))
	{
		DWORD dwError = GetLastError();
		CString strError = _T("");
		strError.Format(_T("执行ShellExecuteEx失败,错误码:%d"), dwError);
		AfxMessageBox(strError);
		return;
	}

	HANDLE hProcess = stuExecInfo.hProcess;
	if (hProcess != NULL)
	{
		WaitForSingleObject(hProcess, INFINITE);
		CloseHandle(hProcess);
	}

#endif

	DWORD dwPID = GameAssist::GetProcessId(_T("Main.exe"));
#if 1
	EnumWindows(GameAssist::EnumChildWindowCallBack, dwPID);

	if (GameAssist::g_vtCtrlInfo.size())
	{
		GameAssist::CtrlInfo* gp = NULL;
		GameAssist::CtrlInfo* gbmin = NULL;
		GameAssist::CtrlInfo* gbentry = NULL;
		for (std::vector<GameAssist::CtrlInfo>::iterator it = GameAssist::g_vtCtrlInfo.begin(); it != GameAssist::g_vtCtrlInfo.end(); it++)
		{
			if (_tcsicmp(it->strWinText.c_str(), _T("最小化")) == 0)
			{
				gbmin = &*it;
			}

			if (_tcsicmp(it->strWinText.c_str(), _T("大话水浒")) == 0)
			{
				gp = &*it;
			}

			if (_tcsicmp(it->strWinText.c_str(), _T("进入游戏")) == 0)
			{
				gbentry = &*it;
			}
		}

		if (gp && gbentry && gbmin)
		{
			//::SendMessage(gp->hwnd, WM_LBUTTONDOWN, (WPARAM)gb->dwId, 0);
			//::SendMessage(gp->hwnd, WM_LBUTTONUP, (WPARAM)gb->dwId, 0);
			// 发送点击事件;
			// 先最小化;
			::SendMessage(gp->hwnd, WM_COMMAND, gbmin->dwId, NULL);
			// 再进入;
			::SendMessage(gp->hwnd, WM_COMMAND, gbentry->dwId, NULL);


			Sleep(1500);
			dwPID = GameAssist::GetProcessId();
			if (dwPID)
			{
				GameAssist::g_vtCtrlInfo.clear();
				EnumWindows(GameAssist::EnumChildWindowCallBack, dwPID);
				HWND hwnd = GameAssist::GetProcessMainWnd(dwPID);
				if (hwnd)
				{
					TCHAR szName[MAX_PATH] = { 0 };
					::GetWindowText(hwnd, szName, MAX_PATH);
					CRect rc;
					::GetWindowRect(hwnd, &rc);
					TCHAR szLogMsg[MAX_PATH] = { 0 };
					_stprintf_s(szLogMsg, _T("窗口标题：%s, [%d,%d, %d,%d], width=%d, height=%d\n"), szName, rc.top, rc.left, rc.right, rc.bottom, rc.Width(), rc.Height());
					OutputDebugString(szLogMsg);
					if (1)
					{ // 800x600
						// 发送按钮消息;进入游戏;
						GameAssist::MouseClick({ 585, 116 });
						// 发送按钮消息;下一步;
						GameAssist::MouseClick({ 536, 481 });
						// 发送按钮消息;电信一区;
						GameAssist::MouseClick({ 229, 342 });
						// 发送按钮消息;忘忧谷;
						GameAssist::MouseClick({ 335, 244 });
						// 发送按钮消息;下一步;
						GameAssist::MouseClick({ 559, 516 });
					}
					else
					{
						// 640x480
						// 发送按钮消息;进入游戏;
						GameAssist::MouseClick({ 440, 75 });
						// 发送按钮消息;下一步;
						GameAssist::MouseClick({ 468, 454 });
						// 发送按钮消息;电信一区;
						GameAssist::MouseClick({ 165, 241 });
						// 发送按钮消息;忘忧谷;
						GameAssist::MouseClick({ 289, 195 });
						// 发送按钮消息;下一步;
						GameAssist::MouseClick({ 494, 469 });
					}
				}
			}
		}
	}
#endif
}


void CGameAssistDlg::OnBnClickedButton2()  // 截图;
{
	HWND hWnd = GetCurGameWnd();
	if (hWnd == NULL)
		return;
	UpdateData();
	INT nX = GetDlgItemInt(IDC_EDIT3);
	INT nY = GetDlgItemInt(IDC_EDIT4);
	INT nX2 = GetDlgItemInt(IDC_EDIT5);
	INT nY2 = GetDlgItemInt(IDC_EDIT6);
	BOOL bCropPicture = ((CButton*)GetDlgItem(IDC_CHECK5))->GetCheck();

	if (bCropPicture)
	{
		std::string strImg = GameGlobal::g_szTempDir;
		strImg.append(_T("裁剪结果.bmp"));
		ImgAssist::CropPicture(hWnd, { nX, nY, nX2, nY2 }, strImg.c_str());
	}
	else
	{
		CString strImg;
		strImg = CTime::GetCurrentTime().Format("%H%M%S-Game.bmp");
		//ImgAssist::CaptureGameWnd(hWnd, strImg.GetString());
		ImgAssist::CaptureWnd(hWnd);
	}
}


void CGameAssistDlg::OnBnClickedButton3() // 镜妖;
{
	UpdateData();
	/*
	-- 是否在星秀村
	-- 是否在贫民房
		|-- 否：我帮您抓
		|-- -- 是否进入过贫民房
		|		|-- 否：我这就去
		|		|	|-- 选择：幸运镜妖
		|		|	|-- 我就选择它
		|		|-- 是：直接进入贫民房
		|-- 是：找到镜妖NPC
		|		|-- 我来抓您的
		|		|
		|		|
		|
		|
	*/
	int nZJType = 0;
	if (m_cbZJ.GetCheck() || m_cbZJ2.GetCheck())
	{
		if (m_cbZJ.GetCheck())
			nZJType = 1;
		if (m_cbZJ2.GetCheck())
			nZJType = 2;
	}

	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		pAction->m_bHasSummoner = m_cbSummoner.GetCheck();
		pAction->m_nSummonerSkillType = nZJType;
		pAction->m_bTargetOfRoleSkill = m_cbAggressiveSkill.GetCheck();
		pAction->StartBattleJY();
	}
}


void CGameAssistDlg::OnBnClickedButton4() // 周六领礼物
{
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		pAction->GetSaturdayPresents();
	}
}


void CGameAssistDlg::OnBnClickedButton5() // 开宝箱;
{
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		pAction->OpenChest(20);
	}
}

const char g_szHeros[12][10] = { "医师独侠","术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠","寒星独侠" };
void CGameAssistDlg::OnBnClickedButton6() // 职业挑战;
{
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		if (!pAction->FindNPCByWorldMap("职业训导大师"))
			return;
		// 选择进入;
		BOOL bMatch = FALSE;
		int trySize = 20;

		// 我要挑战他们;
		while (!(bMatch = pAction->ClickDlgSetup(_T("img\\zyxdds-wytztm.bmp")))) {
			SRAND(1200, 2200);
			if (!trySize--) break;
		}

		// 准备好了
		if (pAction->ClickDlgSetup(_T("img\\zyxdds-zbhl.bmp")))
		{
			// 地图切换，等出图;
			SRAND(2000, 2500);
			if (pAction->IsOnMap(_T("img\\gdd\\name.bmp")))
			{
				pAction->FightingYS("缚神诀");
				for (int i = 1; i < 12; i++)
				{
					pAction->FightingOthers(g_szHeros[i], "缚神诀");
				}
			}
		}
	}
}

void CGameAssistDlg::OnBnClickedButton7()	// 家园任务;
{
	// TODO: 在此添加控件通知处理程序代码
}

void CGameAssistDlg::OnBnClickedButton8() // 职业挑战2;
{
	CComboBox* pList = (CComboBox*)GetDlgItem(CB_HERO);
	int nIndex = pList->GetCurSel();
	if (nIndex == CB_ERR)
		return;
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		for (int i = nIndex; i < 12; i++)
		{
			//SRAND(250, 350);
			//pAction->SendKey(VK_A, FALSE, TRUE);
			if (pAction->IsSPBelowSafeValue(TRUE, TRUE, 30))
			{
				DebugLog(_T("低SP安全值"));
				// 右键;
				pAction->MouseMove({ (GameAssist::g_rcRoleIdleSP.right + GameAssist::g_rcRoleIdleSP.left) / 2 - 3, (GameAssist::g_rcRoleIdleSP.bottom + GameAssist::g_rcRoleIdleSP.top) / 2 - 20 });
				pAction->MouseRClick({ (GameAssist::g_rcRoleIdleSP.right + GameAssist::g_rcRoleIdleSP.left) / 2 - 3, (GameAssist::g_rcRoleIdleSP.bottom + GameAssist::g_rcRoleIdleSP.top) / 2 - 20 });
			}

			pAction->FightingOthers(g_szHeros[i], "缚神诀");
		}
	}
}

void CGameAssistDlg::OnBnClickedButton9() // 移动到目标点
{
	UpdateData();
	INT nX = GetDlgItemInt(IDC_EDIT1);
	INT nY = GetDlgItemInt(IDC_EDIT2);
	BOOL bOpenMap = ((CButton*)GetDlgItem(IDC_CHECK4))->GetCheck();
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		if (bOpenMap)
			pAction->WorldMapPositioning({ nX, nY });
		else
			pAction->MouseMove({ nX, nY });
	}
}


void CGameAssistDlg::OnBnClickedButton10() // Alt+A
{
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		while (true)
		{
			BOOL bFirst = TRUE;
			while (pAction->IsFighting())
			{
				if (pAction->IsWattingAttack(-1))
				{
					SRAND(250, 350);
					pAction->SendKey(VK_A, FALSE, TRUE);
				}
				Sleep(650);
			}

			if (pAction->IsSPBelowSafeValue(TRUE, TRUE, 10))
			{
				DebugLog(_T("低SP安全值"));
				// 右键;
				pAction->MouseMove({ (GameAssist::g_rcRoleIdleSP.right + GameAssist::g_rcRoleIdleSP.left) / 2 - 3, (GameAssist::g_rcRoleIdleSP.bottom + GameAssist::g_rcRoleIdleSP.top) / 2 - 20 });
				pAction->MouseRClick({ (GameAssist::g_rcRoleIdleSP.right + GameAssist::g_rcRoleIdleSP.left) / 2 - 3, (GameAssist::g_rcRoleIdleSP.bottom + GameAssist::g_rcRoleIdleSP.top) / 2 - 20 });
			}

			Sleep(800);
		}
	}
}


void CGameAssistDlg::OnBnClickedButton11() // 刷新;
{
	std::vector<DWORD> vtPID;
	GameAssist::GetAllProcessId(vtPID);
	GameAssist::GetAllProcessMainWnd(vtPID, GameAssist::g_vtGameWndInfo);

	int nIndx = 0;
	m_cbGameRole.ResetContent();
	for (std::vector<GameAssist::GameWndInfo>::iterator it = GameAssist::g_vtGameWndInfo.begin(); it != GameAssist::g_vtGameWndInfo.end(); it++)
	{
		if (it->strGameRoleName.size() == 0)
			continue;
		if (it->pAction == NULL)
			it->pAction = new GameAssist::CAction(it->hWnd);
		nIndx = m_cbGameRole.AddString(it->strGameRoleName.c_str());
		m_cbGameRole.SetItemDataPtr(nIndx, &*it);
	}
	m_cbGameRole.SetCurSel(0);
}


void CGameAssistDlg::OnBnClickedButton12() // 野练技能;
{
	std::map<std::string, int> SkillMap = {
		{"F1",VK_F1},
		{"F2",VK_F2},
		{"F3",VK_F3},
		{"F4",VK_F4},
		{"F5",VK_F5},
		{"F6",VK_F6},
		{"F7",VK_F7},
		{"F8",VK_F8},
	};

	BOOL bCheckAttack = ((CButton*)GetDlgItem(IDC_CHECK_ATTACK))->GetCheck();
	CString strSkill;
	int nCurSel = m_cb_skill_list.GetCurSel();
	if (nCurSel == CB_ERR)
		return;

	m_cb_skill_list.GetLBText(nCurSel, strSkill);

	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		pAction->m_nSkillShortcutKey = SkillMap.find(strSkill.GetString())->second;
		pAction->m_bTargetOfRoleSkill = bCheckAttack;
		pAction->StartSkill();
	}
}

void CGameAssistDlg::OnBnClickedButton13() // 地图找挑战NPC;
{
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
		int nCurSel = m_cbZYNPC.GetCurSel();
		if (nCurSel == CB_ERR)
			return;

		CString strNPC;
		m_cbZYNPC.GetLBText(nCurSel, strNPC);
		auto it = GameAssist::g_mapZYNPC.find(strNPC.GetString());
		if (it != GameAssist::g_mapZYNPC.end())
		{
			pAction->WorldMapPositioning({ it->second.x, it->second.y });
		}
	}
}


void CGameAssistDlg::OnBnClickedButton14()
{
	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
	if (pGameInfo && pGameInfo->pAction)
	{
		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;

		CRect rc = pAction->FindMatchIcon(_T(".\\img\\交子唤神.bmp"));
		if (rc.IsRectEmpty() || rc.IsRectNull())
		{
			MessageBox(_T("未找到交子唤神按钮"));
			return;
		}

		INT X = (rc.right + rc.left) / 2;
		INT Y = (rc.top + rc.bottom) / 2;
		INT nCount = GetDlgItemInt(IDC_EDIT7);
		if (pAction)
		{
			pAction->MouseMove({ X,Y });
			for (size_t i = 0; i < nCount; i++)
			{
				pAction->MouseClick();
				SRAND(850, 1050);
				SetDlgItemInt(IDC_EDIT7, nCount - i);
			}
		}
	}
}
