閑著無聊寫了這一款外掛,現在po出來
希望大家借鑒學習
利用的是dfs算法
沒有抓包
沒有數據的調用
就是像素的截取和自動化的思想
網絡上應該有很多這種東西
我就是借鑒別人的思想,加上自己的理解
希望利用這個例子向大家說明軟件工程還是很有意思的
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include "resource.h"
#include <iostream>
#include <unistd.h>
using namespace std;
HINSTANCE hInst;
BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg){
case WM_INITDIALOG:{}
return TRUE;
case WM_CLOSE:{EndDialog(hwndDlg,
0);}
return TRUE;
case WM_COMMAND:{
switch(LOWORD(wParam)){}}
return TRUE;}
return FALSE;
}
static int dx[]={
0,
1,
0,-
1};
static int dy[]={
1,
0,-
1,
0};
static bool vis[
15][
20];
static long long pic[
15][
20];
static long long empty=
3982280800;
static bool toshutdown;
static int xx=-
1,yy=-
1,xxx,yyy;
static bool inboard(
int x,
int y);
static bool dfs(
int x,
int y,
int dir,
int turn);
bool find(
int x,
int y)
{xx=x,yy=y;
for(
int i=
0;i<
4;i++){memset(vis,
0,
sizeof(vis));vis[x][y]=
true;
if(inboard(x+dx[i],y+dy[i])&&dfs(x+dx[i],y+dy[i],i,
0))
return true;}
return false;
}
bool match()
{
for(
int i=
0;i<
11;i++)
for(
int j=
0;j<
19;j++){
if(pic[i][j]==empty)
continue;
if(find(i,j))
return true;}
return false;
}
bool inboard(
int x,
int y)
{
return x>=
0&&y>=
0&&x<
11&&y<
19;
}
bool dfs(
int x,
int y,
int dir,
int turn)
{
if(vis[x][y]||turn>
2)
return false;vis[x][y]=
true;
if(pic[x][y]==pic[xx][yy]){xxx=x,yyy=y;
return true;}
else if(pic[x][y]!=empty)
return false;
for(
int i=
0;i<
4;i++){
if(!inboard(x+dx[i],y+dy[i])||vis[x+dx[i]][y+dy[i]])
continue;
if(dfs(x+dx[i],y+dy[i],i,turn+(dir!=i)))
return true;}
return false;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nShowCmd)
{hInst=hInstance;InitCommonControls();
{
char bb;cout<<
"打開游戲后輸入y按回車, 如果想退出請輸入n按回車"<<endl;cin >> bb;
if (bb==
'y');
else return 0;
while(
1){HWND pWnd=FindWindow(
NULL,
"QQ游戲 - 連連看角色版");
if(pWnd==
NULL){HWND pp=FindWindow(
NULL,
"連連看");RECT rect;GetWindowRect(pp,&rect);
int w1=rect
.right-rect
.left,h1=rect
.bottom-rect
.top;MoveWindow(pp,
0,
0,w1,h1,
false);::SendMessage(pp, WM_LBUTTONDOWN,
NULL, MAKELPARAM(
271,
125));::SendMessage(pp, WM_LBUTTONUP,
NULL, MAKELPARAM(
271,
125));
continue;}
elsebreak;
}HWND hwnd = ::FindWindow(
NULL,
"QQ游戲 - 連連看角色版");RECT rect;GetWindowRect(hwnd,&rect);
int w=rect
.right-rect
.left,h=rect
.bottom-rect
.top;MoveWindow(hwnd,
0,
0,w,h,
false);HDC hDC = ::GetDC(hwnd);toshutdown=
false;cout <<
"恭喜你成功打開了外掛"<<endl;cout <<
"游戲已經開始,請耐心等待,并確定游戲界面在最前"<<endl;
while(
1){Sleep(
500);
int pair=
0;memset(pic,
0,
sizeof(pic));
for(
int i=
0;i<
11;i++){
for(
int j=
0;j<
19;j++){
int x=
13+j*
31+
16,y=
180+i*
35+
18;pic[i][j]+=GetPixel(hDC,x-
8,y-
8);pic[i][j]+=GetPixel(hDC,x-
8,y+
8)<<
8;pic[i][j]+=GetPixel(hDC,x+
8,y-
8)<<
16;pic[i][j]+=GetPixel(hDC,x+
8,y+
8)<<
24;pic[i][j]+=GetPixel(hDC,x,y)<<
32;
if(pic[i][j]!=empty)pair++;}}pair/=
2;
if(match()){pic[xx][yy]=pic[xxx][yyy]=empty;
int x=
13+yy*
31+
16,y=
180+xx*
35+
18;::SendMessage(hwnd,WM_ACTIVATE,MAKELONG(WA_ACTIVE,
NULL),
NULL);::SendMessage(hwnd, WM_LBUTTONDOWN,
NULL, MAKELPARAM(x,y));::SendMessage(hwnd, WM_LBUTTONUP,
NULL, MAKELPARAM(x, y));x=
13+yyy*
31+
16,y=
180+xxx*
35+
18;::SendMessage(hwnd,WM_ACTIVATE,MAKELONG(WA_ACTIVE,
NULL),
NULL);::SendMessage(hwnd, WM_LBUTTONDOWN,
NULL, MAKELPARAM(x,y));::SendMessage(hwnd, WM_LBUTTONUP,
NULL, MAKELPARAM(x, y));pair--;}
if(pair==
103||pair==
104){::SendMessage(hwnd, WM_LBUTTONDOWN,
NULL, MAKELPARAM(
653,
563));::SendMessage(hwnd, WM_LBUTTONUP,
NULL, MAKELPARAM(
653,
563));
continue;}
else continue;
if(toshutdown){toshutdown=
false;
break;}}
}
return 0;}
總結
以上是生活随笔為你收集整理的qq大厅连连看外挂:c++实现的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。