123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716 |
- // GameAssistDlg.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "GameAssist.h"
- #include "GameAssistDlg.h"
- //#include "VideoDXGICaptor.h"
- #include "MouseAssist.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- 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);
- }
- BOOL FindNPC(HWND hWnd, LPCSTR lpszNPC)
- {
- CRect rc;
- //// 打开世界地图;
- GAssist::SendKey(hWnd, VK_TAB); Sleep(500 + rand() % 200);
- if (!GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\寻路窗口.bmp"), rc))
- return FALSE;
- //// 单击寻路窗口;
- GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2)); Sleep(500 + rand() % 200);
- //// 设置剪切板:职业大挑战;
- GAssist::SetClipboardString(lpszNPC); Sleep(200 + rand() % 200);
- //// Ctrl+V
- GAssist::SendKey(hWnd, 0x56, TRUE); Sleep(300 + rand() % 200);
- // 先移动到目标后,才能实现单击;
- GAssist::MouseMove(hWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
- //// 寻路窗口往下50就是目标;
- GAssist::MouseDbClick(hWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
- //// 退出世界地址;
- GAssist::SendKey(hWnd, VK_TAB); Sleep(200 + rand() % 50);
- // 问题:返回TRUE并不表示到寻路到NPC;
- // 是否成功寻路到NPC要对NPC人物进向模板匹配或与NPC对话框模板匹配
- return TRUE;
- }
- BOOL ClickSetup(HWND hWnd, LPCSTR lpszTemplateImage)
- {
- CRect rc;
- TCHAR szTemplateImage[MAX_PATH] = { 0 };
- // 先截图;
- GAssist::SaveHwndToBmpFile(hWnd, GAssist::g_strAppdir + _T("Game.bmp"));
- _stprintf_s(szTemplateImage, _T("%s%s"),GAssist::g_strAppdir.c_str(), lpszTemplateImage);
- if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), szTemplateImage, rc)) {
- // 找到匹配的模块;
- GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
- GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
- Sleep(200 + rand() % 50);// 进入孤独洞要时间切换地图;
- // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
- GAssist::MouseMove(hWnd, CPoint(rc.left + 20 + rand() % 10, rc.top + 30 + rand() % 10));
- Sleep(300 + rand() % 300);// 进入孤独洞要时间切换地图;
- DebugLog(_T("找到目标并单击成功"));
- return TRUE;
- }
- return FALSE;
- }
- // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
- 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);
- }
- 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)
- 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: 在此添加额外的初始化代码
- GAssist::Init();
- 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);
- }
- void CGameAssistDlg::OnBnClickedOpengame()
- {
- #if 1 // 获取游戏标题;
- DWORD dwPid = GAssist::GetProcessId();
- HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
- //HWND hProWnd = GAssist::GetProMainHwnd(5824);
- TCHAR szWinText[MAX_PATH] = { 0 };
- ::GetWindowText(hProWnd, szWinText, MAX_PATH);
- #if 1
- Sleep(1000);
- m_mouseAssist.BindWnd(hProWnd, PT_TYPE::WINDOW_POINT);
- m_mouseAssist.MoveTo(205, 150);
- Sleep(1000);
- m_mouseAssist.MoveTo(250, 250);
- Sleep(1000);
- m_mouseAssist.MoveTo(350, 350);
- Sleep(1000);
- m_mouseAssist.MoveTo(10, 470);
- m_mouseAssist.LeftClick();
- /*GAssist::MouseMove(hProWnd, CPoint(205,150));
- Sleep(2000);
- GAssist::MouseMove(hProWnd, CPoint(100,100), CPoint(250,250));
- Sleep(2000);
- GAssist::MouseMove(hProWnd, CPoint(100,100), CPoint(350,350));*/
- return;
- #endif
- if (0)
- {
- Sleep(1000);
- GAssist::MouseClick(hProWnd, CPoint(205, 150));
- Sleep(1000);
- GAssist::MouseClick(hProWnd, CPoint(235, 150));
- Sleep(1000);
- GAssist::MouseClick(hProWnd, CPoint(275, 150));
- }
- if (0)
- {
- Sleep(1000);
- ::SetForegroundWindow(hProWnd);
- GAssist::DragMouse(hProWnd, CPoint(173, 192), CPoint(295, 190));
- }
- if (0) {
- GAssist::MouseDbClick(hProWnd, CPoint(476, 158));
- }
- if (0)
- {
- GAssist::SendKey(hProWnd, VK_TAB);
- }
- //RECT rc = {0,0,500,500};
- //HBITMAP hb = GAssist::CopyDC2Bitmap(hProWnd, &rc);
- //GAssist::SaveBitmap(hb, "1.bmp");
- //GAssist::SaveHwndToBmpFile(hProWnd, "2.bmp");
- return;
- #endif
- // TODO: 在此添加控件通知处理程序代码
- if (!PathFileExists(GAssist::g_szGameApp))
- {
- MessageBox("游戏程序不存在", "温馨提示");
- return;
- }
- // 设置辅助程序工作目录为游戏目录;
- //SetCurrentDirectory(_T("E:\\dhsh\\shdata\\"));
- SetCurrentDirectory(_T("D:\\tools\\dhsh\\shdata\\"));
- #if 1
- ShellExecute(NULL, "open", GAssist::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 = GAssist::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 = GAssist::FindProcess(_T("Main.exe"));
- #if 1
- EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
- if (GAssist::g_vtGameHwnd.size())
- {
- GAssist::GameHwnd* gp = NULL;
- GAssist::GameHwnd* gbmin = NULL;
- GAssist::GameHwnd* gbentry = NULL;
- for (std::vector<GAssist::GameHwnd>::iterator it = GAssist::g_vtGameHwnd.begin(); it != GAssist::g_vtGameHwnd.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 = GAssist::GetProcessId();
- if (dwPID)
- {
- GAssist::g_vtGameHwnd.clear();
- EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
- HWND hwnd = GAssist::GetProMainHwnd(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
- // 发送按钮消息;进入游戏;
- GAssist::MouseClick(hwnd, 585, 116);
- // 发送按钮消息;下一步;
- GAssist::MouseClick(hwnd, 536, 481);
- // 发送按钮消息;电信一区;
- GAssist::MouseClick(hwnd, 229, 342);
- // 发送按钮消息;忘忧谷;
- GAssist::MouseClick(hwnd, 335, 244);
- // 发送按钮消息;下一步;
- GAssist::MouseClick(hwnd, 559, 516);
- }
- else
- {
- // 640x480
- // 发送按钮消息;进入游戏;
- GAssist::MouseClick(hwnd, 440, 75);
- // 发送按钮消息;下一步;
- GAssist::MouseClick(hwnd, 468, 454);
- // 发送按钮消息;电信一区;
- GAssist::MouseClick(hwnd, 165, 241);
- // 发送按钮消息;忘忧谷;
- GAssist::MouseClick(hwnd, 289, 195);
- // 发送按钮消息;下一步;
- GAssist::MouseClick(hwnd, 494, 469);
- }
- }
- }
- }
- }
- #endif
- }
- void CGameAssistDlg::OnBnClickedButton2()
- {
- // TODO: 在此添加控件通知处理程序代码
- // VideoDXGICaptor vdx;
- // if (vdx.Init())
- // {
- // INT len = 1024 * 1024 * 1024;
- // BYTE* pData = new BYTE[len];
- // vdx.CaptureImage(pData, len);
- // vdx.Deinit();
- // }
- DWORD dwPid = GAssist::GetProcessId();
- HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
- // 截图;
- GAssist::SaveHwndToBmpFile(hProWnd, "Game.bmp");
- }
- void CGameAssistDlg::OnBnClickedButton3() // 镜妖;
- {
- // 获取进程句柄;
- DWORD dwPid = GAssist::GetProcessId();
- HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
- if (GAssist::nGameWndType == GAssist::GW_SMALL)
- {
- //// 地图区域;
- //CRect rc(469,25,635,65);
- //// 判断当前地图;
- //if (GAssist::SaveBitmap(GAssist::CopyDC2Bitmap(hProWnd, rc), GAssist::g_strAppdir + _T("Game.bmp")))
- //{
- // if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\地图\\应天府.bmp"), rc))
- // {
- // }
- // else if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\地图\\应天府.bmp"), rc))
- // {
- // }
- //}
- CRect rc;
- //FIND_NPC(hProWnd, _T("臭美的小米"));
- Sleep(3000);
- // 与小米对话;
- //if (!GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\1-我帮您抓.bmp"), rc)) {
- // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- // Sleep(200);
- // // 判断是否还有对话,如果没有的话表明不是第一次进入;
- // if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\2-我这就去.bmp"), rc)) {
- // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- // Sleep(200);
- // // 2次对话;
- // if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\3-幸运镜妖.bmp"), rc)) {
- // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- // Sleep(200);
- // // 3次对话;
- // if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\3-我就选择它.bmp"), rc)) {
- // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- // Sleep(200);
- // }
- // }
- // }
- //
- //
- //}
- for (int i = 0; i < 20; i++)
- {
- // 进入贫民房;
- if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\镜妖1.bmp"), rc)) {
- GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2 - 1, (rc.top + rc.bottom) / 2 - 1));
- GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- Sleep(200);
- if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\定位镜妖.bmp"), rc)) {
- GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- Sleep(500);
- // 选择我要打你;
- if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\我来抓您的.bmp"), rc)) {
- GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
- Sleep(500);
- // 判断是否在战斗中;
- while (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\头像.bmp"), rc)) {
- if (rc.left > 60)
- {
- GAssist::ShowLog(_T("战斗中"));
- GAssist::SendKey(hProWnd, 0x41, FALSE, TRUE);
- Sleep(3000);
- }
- else
- {
- GAssist::ShowLog(_T("非战斗"));
- break;
- }
- }
- }
- }
- }
- else {
- static int i = 0;
- if (i == 0)
- {
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(500);
- GAssist::MouseClick(hProWnd, CPoint(225, 305));
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(100);
- i++;
- }
- else if (i == 1)
- {
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(500);
- GAssist::MouseClick(hProWnd, CPoint(300, 266));
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(100);
- i++;
- }
- else if (i == 2)
- {
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(500);
- GAssist::MouseClick(hProWnd, CPoint(175, 280));
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(100);
- i = 0;
- }
- Sleep(2000);
- }
- }
- }
- else if (GAssist::nGameWndType == GAssist::GW_LARGE)
- {
- CRect rc(630, 25, 800, 65);
- if (GAssist::SaveBitmap(GAssist::CopyDC2Bitmap(hProWnd, rc), GAssist::g_strAppdir + _T("dt.bmp")))
- {
- }
- }
- }
- void CGameAssistDlg::OnBnClickedButton4() // 周六领礼物
- {
- // TODO: 在此添加控件通知处理程序代码
- }
- void CGameAssistDlg::OnBnClickedButton5() // 开宝箱;
- {
- HWND hProcessMainWnd = GAssist::GetProcessMainWnd();
- if (GAssist::nGameWndType == GAssist::GW_SMALL)
- {
- CRect rc;
- MouseAssist mouseAssist;
- mouseAssist.BindWnd(hProcessMainWnd, PT_TYPE::SCREEN_POINT);
- for (int i = 0; i < 50; i++)
- {
- if (!GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\应天府铁匠.bmp"), rc))
- {
- // 没找到,要将鼠标从目标中移走;并且要右击一次将目标的高亮状态取消;
- mouseAssist.SetCursorPos(rc.top + rand() % 5, rc.left + rand() % 5);
- mouseAssist.MoveTo(rc.top - rand() % 5, rc.left - rand() % 5);
- mouseAssist.RightClick();
- }
- else
- {
- GAssist::MouseClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 5));
- Sleep(600 + rand() % 30);
- // 再移动下,会更高精度;
- mouseAssist.MoveTo(rc.top - rand() % 15, rc.left - rand() % 15);
- // 判断是否还有对话,如果没有的话表明不是第一次进入;
- if (GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\开宝箱.bmp"), rc)) {
- GAssist::MouseClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2));
- Sleep(rand() % 200 + 190);
- // 然后移动出去;
- //GAssist::MouseMove(hProcessMainWnd, CPoint(rc.top - 50 - rand()%20, rc.left - 50 - rand() % 20));
- mouseAssist.SetCursorPos(rc.top + rand() % 5, rc.left + rand() % 5);
- mouseAssist.MoveToEx(rc.top, rc.left, rc.Width(), rc.Height());
- }
- }
- Sleep(600 + rand() % 300);
- }
- }
- }
- void CGameAssistDlg::OnBnClickedButton6() // 职业挑战;
- {
- CRect rc;
- DebugLog(_T("进入孤独洞========="));
- HWND hProWnd = GAssist::GetProcessMainWnd();
- //// 打开世界地图;
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(500 + rand() % 200);
- if (!GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\寻路窗口.bmp"), rc))
- return;
- //// 单击寻路窗口;
- GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2)); Sleep(500 + rand() % 200);
- //// 设置剪切板:职业大挑战;
- GAssist::SetClipboardString("职业训导大师"); Sleep(200 + rand() % 200);
- //// Ctrl+V
- GAssist::SendKey(hProWnd, 0x56, TRUE); Sleep(300 + rand() % 200);
- // 先移动到目标后,才能实现单击;
- GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
- //// 寻路窗口往下50就是目标;
- GAssist::MouseDbClick(hProWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
- //// 退出世界地址;
- GAssist::SendKey(hProWnd, VK_TAB); Sleep(200 + rand() % 50);
- // 选择进入;
- BOOL bMatch = FALSE;
- int trySize = 20;
- // 我要挑战他们;
- while (!(bMatch = GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\zyxdds-wytztm.bmp"), rc))) {
- Sleep(3000 + rand() % 500);
- // 截图;
- GAssist::SaveHwndToBmpFile(hProWnd, GAssist::g_strAppdir + _T("Game.bmp"));
- GAssist::MouseMove(hProWnd, CPoint(rc.left + rand()%10, rc.top+rand()%10));
- if (!trySize--) break;
- }
- if (bMatch) {
- GAssist::MouseMove(hProWnd, CPoint(rc.left, rc.top));
- // 单击:我要挑战他们;
- GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
- Sleep(2000 + rand()%500 );// 等出图;
- // 移动一下;
- GAssist::MouseMove(hProWnd, CPoint(rc.left, rc.top));
- ::SetCursorPos(rc.left + rand()%6, rc.top + rand()%8);
- trySize = 5;
- bMatch = FALSE;
- // 再单击:我准备好了;
- GAssist::SaveHwndToBmpFile(hProWnd, GAssist::g_strAppdir + _T("Game.bmp"));
- while (!(bMatch = GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\zyxdds-zbhl.bmp"), rc))) {
- GAssist::MouseMove(hProWnd, CPoint(rc.left + rand() % 20, rc.top + rand() % 20));
- Sleep(200 + rand()%200);//等进入地图;
- if (!trySize--) break;
- }
- if ( bMatch ) {
- GAssist::MouseMove(hProWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
- GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
- Sleep(1500 + rand()%300);// 进入孤独洞要时间切换地图;
- DebugLog(_T("进入孤独洞1"));
- // 判断是否在孤独洞;
- GAssist::SaveHwndToBmpFile(hProWnd, GAssist::g_strAppdir + _T("Game.bmp"));
- if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\gdd\\name.bmp"), rc)) {
- DebugLog(_T("进入孤独洞2"));
- char szName[11][32] = { "医师独侠","术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
- for (int i = 0; i < 10; i++)
- {
- if (FindNPC(hProWnd, szName[i]))
- {
- if (_tcscmp(szName[i], _T("医师独侠")) == 0)
- {
- Sleep(5500 + rand()%300); // 等你走到她面前;
- if (ClickSetup(hProWnd, "img\\jn-jk\\gdd\\xyy.bmp"))
- {
- // 选择技能:缚神诀;
- if (ClickSetup(hProWnd, "img\\jn-jk\\gdd\\fsj.bmp"))
- {
- if (!ClickSetup(hProWnd, "\\img\\jn-jk\\gdd\\qd.bmp"))
- break;
- Sleep(200+rand()%30);
- if (!ClickSetup(hProWnd, "\\img\\jn-jk\\gdd\\qd.bmp"))
- break;
- Sleep(100 + rand()%50);
- // 打6下;
- for (size_t i = 0; i < 5; i++)
- {
- // 缚神诀的快捷键是:F6
- GAssist::SendKey(hProWnd, VK_F6);
- Sleep(1600+rand()%300);
- }
- }
- }
- break;
- }
- else
- {
- }
- }
- Sleep(200 + rand()%300);
- DebugLog(_T("进入孤独洞2:%s"), szName[i]);
- }
- }
- }
- }
- }
|