|
发表于 2019-2-21 12:35:42
|
显示全部楼层
四川省成都市
本帖最后由 Jewelry 于 2019-2-21 12:37 编辑
- #include"Helper.h"
- HWND childhwnd = NULL;
- VOID SingleClick(int x, int y)
- {
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(x, y));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(x, y));
- }
- VOID InitialHwnd()
- {
- HWND hWnd = FindWindow(NULL, L"雷电模拟器");
- if (hWnd != NULL)
- {
- POINT pt;
- int x = 0, y = 0;
- if (hWnd != NULL)
- {
- childhwnd = FindWindowEx(hWnd, 0, NULL, L"TheRender");
- if (childhwnd != NULL)
- {
- ShowWindow(hWnd, SW_NORMAL);
- /*SetForegroundWindow(hWnd);*/
- /*MessageBox(NULL, L"Initialize Successfully!!!", L"Nice", NULL);*/
- printf("Initialize successfully!!!");
- }
- }
- }
- return;
- }
- unsigned WINAPI LoginProc(LPVOID)
- {
- // 启动
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(820, 120));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(820, 120));
- Sleep(12 * 1000);
- // 登陆
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(650, 490));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(650, 490));
- return 0;
- }
- unsigned WINAPI Seige(LPVOID)
- {
- for (int i = 0; i < 3; i++)
- {
- SingleClick(1146, 72);
- SingleClick(1146, 72);
- // 1.军事
- SingleClick(64, 651);
- Sleep(1000);
- // 2.攻城掠地
- SingleClick(161, 534);
- Sleep(2000);
- // 3.搜索对手
- SingleClick(855, 503);
- Sleep(1000);
- // 4.出征
- SingleClick(640, 586);
- Sleep(10 * 1000);
- // 下兵
- SingleClick(1148, 61);
- SingleClick(1139, 55);
- SingleClick(20, 110);
- SingleClick(20, 110);
- SingleClick(1139, 55);
- Sleep(20 * 1000);
- // 5.撤退
- SingleClick(146, 487);
- SingleClick(146, 487);
- Sleep(2000);
- // 6.确认
- SingleClick(731, 472);
- Sleep(3000);
- // 7.回营
- SingleClick(1065, 633);
- Sleep(1000);
- SingleClick(1065, 633);
- Sleep(7 * 1000);
- }
- return 0;
- }
- unsigned WINAPI Dominate(LPVOID)
- {
- // 1.军事
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(64, 651));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(64, 651));
- Sleep(1000);
- // 2.群雄争霸
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(232, 655));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(232, 655));
- Sleep(1000);
- // 3.开始战斗
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(705, 643));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(705, 643));
- Sleep(2000);
- // 4.出征
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(640,586));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(640, 586));
-
- Sleep(10 * 1000);
- PostMessage(childhwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(152, 492));
- PostMessage(childhwnd, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(152, 492));
- return 0;
- }
复制代码- #pragma once
- #include<Windows.h>
- #include<stdio.h>
- // 初始化窗口句柄
- VOID InitialHwnd();
- VOID SingleClick(int x,int y);
- // 登陆
- unsigned WINAPI LoginProc(LPVOID);
- // 攻城战
- unsigned WINAPI Seige(LPVOID);
- unsigned WINAPI Dominate(LPVOID);
复制代码
#include"Helper.h"
#include<process.h>
int main()
{
HANDLE hThread;
unsigned ThreadId;
InitialHwnd();
/*hThread = (HANDLE)_beginthreadex(NULL, 0, LoginProc, NULL, 0, &ThreadId);
if (hThread == NULL)
{
printf("Login failed!!!\n");
}*/
hThread = (HANDLE)_beginthreadex(NULL, 0, Seige, NULL, 0, &ThreadId);
if (hThread == NULL)
{
printf("Mession failed!!!\n");
}
WaitForSingleObject(hThread, INFINITE);
system("pause");
return 0;
} |
|