📄 qq对对碰外挂.txt
字号:
代码只供研究之用.
#include "stdafx.h"
#include "resource.h"
#include <stdio.h>
#include <time.h>
int CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int GetAnimalPos(int nAnimalData[], int nData, int n);
void Move(int nAnimal[][8], int& x1, int& y1, int& nDir);
int Eat(int nAnimal[][8], int x, int y, int nDir1, int nOrg);
int nXMouseStep = 65535 / GetSystemMetrics(SM_CXFULLSCREEN);
int nYMouseStep = 65535 / GetSystemMetrics(SM_CYSCREEN);
int nXGameStartBtn = 390;
int nYGameStartBtn = 390;
int nXCryFaceTool = 447;
int nYCryFaceTool = 513;
DWORD dwMyWndWidth = 220;
DWORD dwMyWndHeight = 220;
bool bIsAutoTool = false;
bool bIsAutoGame = false;
RECT stGameRect;
int nXoffset = stGameRect.left + 270 + 35, nYOffset = stGameRect.top + 95 + 14;
int nXGameScreenOffset = 290, nYGameScreenOffset = 115;
int nBmpWidth = 48, nBmpHeight = 48;
DWORD dwColor = 0;
int nAnimalData[8] = {16316664, 5808232, 5789784, 1583184, 1599624, 1600656, 8422528, 11540600};
DWORD dwGameStartBtnData = 8918168;
DWORD dwCryFaceData = 46328;
DWORD dwNotToolData = 8935432;
char* szAnimalName[8] = {"小牛", "青蛙", "熊猫", "猴子", "小鸡", "小鸡", "小猫", "小狗"};//七只动物
char* szDir[5] = {"左", "右", "上", "下"};
HDC hDC = NULL;
char cNumber1VirtualKey = 49;
char cNumber2To4VirtualKey[3] = {50, 51, 52};
int nAnimal[8][8];
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
DialogBox(NULL, MAKEINTRESOURCE(IDD_ABOUTBOX), NULL, About);
return 0;
}
HMODULE hModule = NULL;
bool bIsStart = false;
HWND hGameWnd;
typedef void(*SetHookDef)();
SetHookDef pSetHook;
int CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
if(lParam != 1)
{
srand(time(0));
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "欢迎使用本软件.");
MoveWindow(hDlg, 800, 200, 220, 180, false);
SetTimer(hDlg, 1, 300, NULL);
SetTimer(hDlg, 2, 100, NULL);
SetTimer(hDlg, 3, 300, NULL);
hModule = LoadLibrary("TestDll.dll");
pSetHook = (SetHookDef)GetProcAddress(hModule, "SetHook");
pSetHook();
MoveWindow(hDlg, GetSystemMetrics(SM_CXFULLSCREEN) / 3, GetSystemMetrics(SM_CYSCREEN) / 3, dwMyWndWidth, dwMyWndHeight, true);
SendMessage(GetDlgItem(hDlg, IDC_CHK_AUTO_GAME), BM_SETCHECK, 1, 0 );
SendMessage(GetDlgItem(hDlg, IDC_CHK_AUTO_TOOL), BM_SETCHECK, 1, 0 );
SetWindowText(GetDlgItem(hDlg, IDC_BTN_START), "开始");
}
return (INT_PTR)TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_BTN_START:
hGameWnd = FindWindow(NULL, "对对碰角色版");
RECT stGameRect;
GetWindowRect(hGameWnd, &stGameRect);
if(hGameWnd == NULL)
{
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "请启动游戏,再继续.");
break;
}
bIsStart = true;
MoveWindow(hGameWnd, 0, 0, stGameRect.right - stGameRect.left, stGameRect.bottom - stGameRect.top, true);
GetWindowRect(hGameWnd, &stGameRect);
MoveWindow(hDlg, stGameRect.right, stGameRect.top + 50, dwMyWndWidth, dwMyWndHeight, true);
ShowWindow(hGameWnd, SW_SHOW);
SetForegroundWindow(hGameWnd);
if(SendMessage(GetDlgItem(hDlg, IDC_CHK_AUTO_GAME), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) //是否按下了 单文件按键
bIsAutoGame = true;
if(SendMessage(GetDlgItem(hDlg, IDC_CHK_AUTO_TOOL), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) //是否按下了 单文件按键
bIsAutoTool = true;
SetWindowText(GetDlgItem(hDlg, IDC_BTN_START), "暂停");
break;
case IDC_BUTTON1:
EndDialog(hDlg, 0);
break;
case IDC_BTN_ABOUT:
DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_ABOUT), hDlg, About, 1);
break;
}
break;
case WM_TIMER:
{
if(wParam == 2)
{
char szWndText[128];
GetWindowText(hDlg, szWndText, 128);
if(strcmp(szWndText, "QQ对对碰外挂 ") == 0)
{
if(bIsStart == false)
{
hGameWnd = FindWindow(NULL, "对对碰角色版");
if(hGameWnd == NULL)
{
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "请启动游戏,再继续.");
break;
}
bIsStart = true;
if(SendMessage(GetDlgItem(hDlg, IDC_CHK_AUTO_GAME), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) //是否按下了 单文件按键
bIsAutoGame = true;
if(SendMessage(GetDlgItem(hDlg, IDC_CHK_AUTO_TOOL), BM_GETCHECK, 0, 0 ) == BST_CHECKED ) //是否按下了 单文件按键
bIsAutoTool = true;
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "启动外挂");
}
else
{
SetWindowText(hDlg, "QQ对对碰外挂");
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "暂停外挂");
SetWindowText(GetDlgItem(hDlg, IDC_BTN_START), "开始");
bIsStart = false;
}
}
}
if(bIsStart == false)
break;
hGameWnd = FindWindow(NULL, "对对碰角色版");
if(hGameWnd == NULL)
return 0;
hDC = GetDC(NULL);
GetWindowRect(hGameWnd, &stGameRect);
//自动准备游戏
if(bIsAutoGame && GetPixel(hDC, stGameRect.left + nXGameStartBtn, stGameRect.top + nYGameStartBtn) == dwGameStartBtnData)
{
mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
nXMouseStep*(stGameRect.left + nXGameStartBtn),
nYMouseStep*(stGameRect.top + nYGameStartBtn), NULL, NULL);
mouse_event( MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,
nXMouseStep*(stGameRect.left + nXGameStartBtn),
nYMouseStep*(stGameRect.top + nYGameStartBtn), NULL, NULL);
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "准备游戏中");
}
if(bIsAutoTool && wParam == 3) //自动放工具时间事件
{
DWORD dwToolBarData= GetPixel(hDC, stGameRect.left + nXCryFaceTool, stGameRect.top + nYCryFaceTool);
if(dwNotToolData == dwToolBarData)return 0;
if(GetPixel(hDC, stGameRect.left + nXCryFaceTool, stGameRect.top + nYCryFaceTool)
!= dwCryFaceData)//不是笑脸的工具
{
keybd_event(cNumber1VirtualKey, NULL, 0, NULL);
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "放了一个小工具");
}
else
{
keybd_event(cNumber2To4VirtualKey[rand()%3], NULL, 0, NULL);
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), "放了一个小笑脸");
}
return 0;
}
for(int y = 0; y < 8; y++)
{
for(int x = 0; x < 8; x++)
{
dwColor = GetPixel(hDC, nXoffset + x * nBmpWidth, nYOffset + y * nBmpHeight);
int nPos = GetAnimalPos(nAnimalData, dwColor, 8);
nAnimal[x][y] = nPos;
nAnimal[x][y] == 5 ? nAnimal[x][y] = 4 : nAnimal[x][y];//索引4,5都是鸡
}
}
if(hDC)ReleaseDC(NULL, hDC);
int nMoveX = -1, nMoveY = -1, nDir = -1;
Move(nAnimal, nMoveX, nMoveY, nDir);
if(nMoveX != -1 && nMoveY != -1 && nDir != -1)
{
if( nAnimal[nMoveX][nMoveY] >= 0 && nAnimal[nMoveX][nMoveY] < 8)
{
char szText[100];
sprintf(szText, "X:%d Y:%d 方向:%s %s", nMoveX + 1, nMoveY + 1, szDir[nDir], szAnimalName[nAnimal[nMoveX][nMoveY]]);
SetWindowText(GetDlgItem(hDlg, IDC_EDIT1), szText);
}
mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + nMoveX * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + nMoveY * nBmpHeight), NULL, NULL);
mouse_event( MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + nMoveX * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + nMoveY * nBmpHeight), NULL, NULL);
// Sleep(5);
if(nDir == 0)
{
mouse_event(MOUSEEVENTF_ABSOLUTE |MOUSEEVENTF_MOVE,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + (nMoveX + 1) * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + nMoveY * nBmpHeight), NULL, NULL);
mouse_event( MOUSEEVENTF_LEFTDOWN ,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + (nMoveX + 1) * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + nMoveY * nBmpHeight), NULL, NULL);
}
else if(nDir == 1)
{
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + (nMoveX - 1) * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + nMoveY * nBmpHeight), NULL, NULL);
mouse_event( MOUSEEVENTF_LEFTDOWN ,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + (nMoveX - 1) * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + nMoveY * nBmpHeight), NULL, NULL);
}
else if(nDir == 2)
{
mouse_event(MOUSEEVENTF_ABSOLUTE |MOUSEEVENTF_MOVE,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + nMoveX * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + (nMoveY - 1)* nBmpHeight), NULL, NULL);
mouse_event( MOUSEEVENTF_LEFTDOWN ,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + nMoveX * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + (nMoveY - 1)* nBmpHeight), NULL, NULL);
}
else if(nDir == 3)
{
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + nMoveX * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + (nMoveY + 1) * nBmpHeight), NULL, NULL);
mouse_event( MOUSEEVENTF_LEFTDOWN ,
nXMouseStep*(stGameRect.left + nXGameScreenOffset + nMoveX * nBmpWidth),
nYMouseStep*(stGameRect.top + nYGameScreenOffset + (nMoveY + 1) * nBmpHeight), NULL, NULL);
}
// Sleep(rand()%50 + 10);
}
}
break;
case WM_CLOSE:
KillTimer(hDlg, 1);
KillTimer(hDlg, 2);
KillTimer(hDlg, 3);
FreeLibrary(hModule);
ExitProcess(0);
break;
}
return (INT_PTR)FALSE;
}
int GetAnimalPos(int nAnimalData[], int nData, int n)
{
for(int i = 0; i < n; i++)
if(nAnimalData[i] == nData)
return i;
return -1;
}
void Move(int nAnimal[][8], int& x1, int& y1, int& nDir)
{
for(int x = 0; x < 8; x++)
{
for(int y = 0; y < 8; y++)
{
//左
if((x + 1 < 8) && Eat(nAnimal, x + 1, y, 0, nAnimal[x][y]) != -1)
{
x1 = x, y1 = y, nDir = 0;
return;
}
//右
if((x - 1 >= 0) && Eat(nAnimal, x - 1, y, 1, nAnimal[x][y]) != -1)
{
x1 = x, y1 = y, nDir = 1;
return;
}
//上
if((y - 1 >= 0) && Eat(nAnimal, x, y - 1, 2, nAnimal[x][y]) != -1)
{
x1 = x, y1 = y, nDir = 2;
return;
}
//下
if((y + 1 < 8) && Eat(nAnimal, x, y + 1, 3, nAnimal[x][y]) != -1)
{
x1 = x, y1 = y, nDir = 3;
return;
}
}
}
x1 = -1, y1 = -1, nDir = -1;
}
int Eat(int nAnimal[][8], int x, int y, int nDir1, int nOrg)
{
if((nDir1 == 1 || nDir1 == 0) && y - 1 >= 0 && y + 1 < 8 && nOrg == nAnimal[x][y-1] && nOrg == nAnimal[x][y+1]) //左右
return 0;
if((nDir1 == 2 || nDir1 == 3) && x - 1 >= 0 && x + 1 < 8 && nOrg == nAnimal[x-1][y] && nOrg == nAnimal[x+1][y])//上下
return 0;
if(nDir1 != 1 && x + 2 < 8 && nOrg == nAnimal[x+1][y] && nAnimal[x+1][y] == nAnimal[x+2][y]) //左3个是不是一样
return 0;
if(nDir1 != 0 && x - 2 >= 0 && nOrg == nAnimal[x-1][y] && nAnimal[x-1][y] == nAnimal[x-2][y]) //右3个是不是一样
return 0;
if(nDir1 != 3 && y - 2 >= 0 && nOrg == nAnimal[x][y-1] && nAnimal[x][y-1] == nAnimal[x][y-2]) //上3个是不是一样
return 0;
if(nDir1 != 2 && y + 2 < 8 && nOrg == nAnimal[x][y+1] && nAnimal[x][y+1] == nAnimal[x][y+2]) //下3个是不是一样
return 0;
return -1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -