1 Star 0 Fork 0

xfgryujk/AutoMineSweeper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
AutoMineSweeper.cpp 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
xfgryujk 提交于 2014-09-30 19:20 . Update
#include "stdafx.h"
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// !!! REPLACE ClassName AND WindowName WITH YOUR winmine.exe's
HWND hwnd = FindWindow(_T("ɨ"), _T("ɨ"));
if(hwnd == NULL)
{
MessageBox(NULL, _T("Winmine is not found!"), _T("AutoMineSweeper"), MB_ICONSTOP);
return 1;
}
DWORD pid;
GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
int width, height;
ReadProcessMemory(handle, (LPVOID)0x1005334, &width, sizeof(int), NULL);
ReadProcessMemory(handle, (LPVOID)0x1005338, &height, sizeof(int), NULL);
ShowWindow(hwnd, SW_RESTORE);
SetForegroundWindow(hwnd);
Sleep(300);
for(int y = 1; y <= height; y++)
for(int x = 1; x <= width; x++)
{
BYTE data;
ReadProcessMemory(handle, (LPVOID)(0x1005340 + y * 32 + x), &data, sizeof(BYTE), NULL);
UINT downMsg = 0, upMsg;
if(data == 0x0F) // (data & 1<<7) == 0
{
downMsg = MOUSEEVENTF_LEFTDOWN;
upMsg = MOUSEEVENTF_LEFTUP;
}
else if(data == 0x8F)
{
downMsg = MOUSEEVENTF_RIGHTDOWN;
upMsg = MOUSEEVENTF_RIGHTUP;
}
if(downMsg != 0)
{
RECT rect;
GetClientRect(hwnd, &rect);
POINT curPos = {rect.left + 20 + (x - 1) * 16
, rect.top + 63 + (y - 1) * 16};
ClientToScreen(hwnd, &curPos);
SetCursorPos(curPos.x, curPos.y);
mouse_event(downMsg, 0, 0, 0, 0);
mouse_event(upMsg, 0, 0, 0, 0);
Sleep(20);
}
}
CloseHandle(handle);
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/xfgryujk/AutoMineSweeper.git
git@gitee.com:xfgryujk/AutoMineSweeper.git
xfgryujk
AutoMineSweeper
AutoMineSweeper
master

搜索帮助