暂无描述

Jeff 007e3431fe 更新内容。 5 年之前
GameAssist b270c9c96c 使用mouse_event模拟鼠标时,需要窗口最前; 5 年之前
.gitignore 73ed0b63f6 Initial commit 5 年之前
README.md 007e3431fe 更新内容。 5 年之前

README.md

游戏辅助工具

  • 第一代:基于模拟按键/鼠标、OCR、Opencv图像处理实现游戏辅助工具

一、模拟鼠标操作

SendMessage/PostMessage

  • 移动鼠标:
    • SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(x, y));
  • 单击鼠标:
    • SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y))
    • SendMessage(hwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
    • 注意:鼠标单击事件时,游戏窗口必须顶层,使用SetForegroundWindow(hwnd)切换窗口到顶层;
  • 拖动鼠标:
    • 目前遇到技术难点,实现方式不生效:
    • SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
    • SendMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x, y));
    • SendMessage(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
  • 右键鼠标:
    • SendMessage(hwnd, WM_RBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y))
    • SendMessage(hwnd, WM_RBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
    • 注意:鼠标单击事件时,游戏窗口必须顶层,使用SetForegroundWindow(hwnd)切换窗口到顶层;

mouse_event、key_event

  • 移动鼠标:
    • mouse_event(MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);
    • 需要注意的是MOUSEEVENTF_ABSOLUTE宏是绝对坐标,如果没这个宏使用的是相对坐标,换算更麻烦,建议使用绝对坐标; 单击鼠标:
    • // 屏幕坐标,窗口坐标需要转成屏幕坐标;
    • POINT ptScreen = ptWnd;
    • ClientToScreen(&ptScreen);
    • // 窗口必须显示且位于顶层;
    • ::ShowWindow(hWnd);
    • ::SetForegroundWindow(hWnd);
    • // 在单击前,必须将鼠标位置设置在目标点上,否则无效;
    • ::SetCursorPos(ptScreen.x, ptScreen.y);
    • mouse_event(MOUSEEVENTF_LEFTDOWN, ptScreen.x, ptScreen.y, 0, 0);
    • mouse_event(MOUSEEVENTF_LEFTUP, ptScreen.x, ptScreen.y, 0, 0);
  • 拖动鼠标:
    • // 屏幕坐标,窗口坐标需要转成屏幕坐标;
    • POINT ptSStart = ptWndStart;
    • POINT ptSEnd = ptWndEnd;
    • ClientToScreen(&ptScreen);
    • ClientToScreen(&ptSEnd);
    • // 窗口必须显示且位于顶层;
    • ::ShowWindow(hWnd);
    • ::SetForegroundWindow(hWnd);
    • // 在单击前,必须将鼠标位置设置在目标点上,否则无效;
    • ::SetCursorPos(ptScreen.x, ptScreen.y);
    • mouse_event(MOUSEEVENTF_LEFTDOWN, ptScreen.x, ptScreen.y, 0, 0);
    • mouse_event(MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE, ptSEnd.x, ptSEnd.y, 0, 0);
    • mouse_event(MOUSEEVENTF_LEFTUP, ptSEnd.x, ptSEnd.y, 0, 0);
  • 右键鼠标:
    • // 屏幕坐标,窗口坐标需要转成屏幕坐标;
    • POINT ptScreen = ptWnd;
    • ClientToScreen(&ptScreen);
    • // 窗口必须显示且位于顶层;
    • ::ShowWindow(hWnd);
    • ::SetForegroundWindow(hWnd);
    • // 在单击前,必须将鼠标位置设置在目标点上,否则无效;
    • ::SetCursorPos(ptScreen.x, ptScreen.y);
    • mouse_event(MOUSEEVENTF_REFTDOWN, ptScreen.x, ptScreen.y, 0, 0);
    • mouse_event(MOUSEEVENTF_REFTUP, ptScreen.x, ptScreen.y, 0, 0);

二、游戏截图与图像处理

1、GDI截图

2、DDRAW截图

3、DXGI截图

4、OCR-在线百度ORC

5、图像处理-Opencv