QQ版连连看外挂 [ In C++ / MFC ]
FutureCode
posted @ Tue, 09 Feb 2010 00:08:04 +0800
in Chapter 1 - Applications
, 2275 readers
Introduction
针对QQ版连连看制作的外挂,BFS实现。
程序默认是瞬间完成的,不过也可以设置Click函数末尾的Sleep以添加延迟。
Download Access
Key Source File
void CLLK_WGDlg::OnGo() { // TODO: Add your control notification handler code here HWND hWnd; hWnd = ::FindWindow(NULL, "QQ游戏 - 连连看角色版"); if(hWnd == NULL) { MessageBox("请启动游戏再继续"); return; } ::GetWindowRect(hWnd, &GameRect); nKind = 0; nBlock = 0; int i, j; for(i = 0; i < 21; i++) for(j = 0; j < 13; j++) nMap[i][j] = 99; const COLORREF clBack = RGB(48, 76, 112); const int lenX = 31, lenY = 35; const int startX = GameRect.TopLeft().x + 14, startY = GameRect.TopLeft().y + 181; const int getX = 14, getY = 14; const int nDist = 3; int nGet; COLORREF clA, clB, clC, clD; HDC hDC = ::GetDC(NULL); for(i = 0; i < 19; i++) for(j = 0; j < 11; j++) { clA = ::GetPixel(hDC, startX + i * lenX + getX, startY + j * lenY + getY); clB = ::GetPixel(hDC, startX + i * lenX + getX + nDist, startY + j * lenY + getY); clC = ::GetPixel(hDC, startX + i * lenX + getX, startY + j * lenY + getY + nDist); clD = ::GetPixel(hDC, startX + i * lenX + getX + nDist, startY + j * lenY + getY + nDist); if(ColorCompare(clA, clBack) && ColorCompare(clB, clBack)) { nMap[i + 1][j + 1] = -1; continue; } nGet = CheckColorExistence(clA, clB, clC, clD); if(nGet == -1) { clKind[nKind][0] = clA; clKind[nKind][1] = clB; clKind[nKind][2] = clC; clKind[nKind][3] = clD; nGet = nKind++; } nMap[i + 1][j + 1] = nGet; nBlock++; } int nRet; while(nBlock > 0) { nRet = PrepareForSearch(); if(nRet == 0) return; } } int CLLK_WGDlg::SearchStart(int x, int y, int &matchX, int &matchY) { int nFlag[21][13]; int queue[500][2]; int p = 0, q = 1; queue[0][0] = x; queue[0][1] = y; int i, j; for(i = 0; i < 21; i++) for(j = 0; j < 13; j++) nFlag[i][j] = 999; nFlag[x][y] = 0; while(p < q && nFlag[queue[p][0]][queue[p][1]] <= 2) { if(nFlag[queue[p][0]][queue[p][1]] < nFlag[queue[p][0] - 1][queue[p][1]]) { for(i = queue[p][0] - 1; nMap[i][queue[p][1]] == -1; i--) { nFlag[i][queue[p][1]] = nFlag[queue[p][0]][queue[p][1]] + 1; queue[q][0] = i; queue[q][1] = queue[p][1]; q++; } if(nMap[i][queue[p][1]] == nMap[x][y]) { matchX = i; matchY = queue[p][1]; return 1; } } if(nFlag[queue[p][0]][queue[p][1]] < nFlag[queue[p][0] + 1][queue[p][1]]) { for(i = queue[p][0] + 1; nMap[i][queue[p][1]] == -1; i++) { nFlag[i][queue[p][1]] = nFlag[queue[p][0]][queue[p][1]] + 1; queue[q][0] = i; queue[q][1] = queue[p][1]; q++; } if(nMap[i][queue[p][1]] == nMap[x][y]) { matchX = i; matchY = queue[p][1]; return 1; } } if(nFlag[queue[p][0]][queue[p][1]] < nFlag[queue[p][0]][queue[p][1] - 1]) { for(i = queue[p][1] - 1; nMap[queue[p][0]][i] == -1; i--) { nFlag[queue[p][0]][i] = nFlag[queue[p][0]][queue[p][1]] + 1; queue[q][0] = queue[p][0]; queue[q][1] = i; q++; } if(nMap[queue[p][0]][i] == nMap[x][y]) { matchX = queue[p][0]; matchY = i; return 1; } } if(nFlag[queue[p][0]][queue[p][1]] < nFlag[queue[p][0]][queue[p][1] + 1]) { for(i = queue[p][1] + 1; nMap[queue[p][0]][i] == -1; i++) { nFlag[queue[p][0]][i] = nFlag[queue[p][0]][queue[p][1]] + 1; queue[q][0] = queue[p][0]; queue[q][1] = i; q++; } if(nMap[queue[p][0]][i] == nMap[x][y]) { matchX = queue[p][0]; matchY = i; return 1; } } p++; } return 0; } void CLLK_WGDlg::Click(int x1, int y1, int x2, int y2) { const int lenX = 31, lenY = 35; const int startX = GameRect.TopLeft().x + 14, startY = GameRect.TopLeft().y + 181; const int getX = 14, getY = 14; SetCursorPos(startX + (x1 - 1) * lenX + getX, startY + (y1 - 1) * lenY + getY); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); SetCursorPos(startX + (x2 - 1) * lenX + getX, startY + (y2 - 1) * lenY + getY); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //Sleep(750); } int CLLK_WGDlg::PrepareForSearch() { int i, j; int matchX, matchY; int nRet; for(i = 1; i <= 19; i++) for(j = 1; j <= 11; j++) { if(nMap[i][j] != -1) { nRet = SearchStart(i, j, matchX, matchY); if(nRet == 1) { nMap[i][j] = nMap[matchX][matchY] = -1; Click(i, j, matchX, matchY); nBlock -= 2; return 1; } } } return 0; }
Mon, 08 Aug 2011 23:27:23 +0800
1
Fri, 26 Feb 2021 23:47:59 +0800
Most of the students have stepped into the field of programming. get diamond online QQ version of the Lianliankan plug-in helps students to have the interest to create new programs and get appropriate results for them. Very informative, thanks for sharing.
Sun, 02 Jan 2022 05:16:36 +0800
When I originally commented I clicked the -Notify me when new surveys are added- checkbox now when a comment is added I receive four emails with the exact same comment. Could there be any way you are able to remove me from that service? Thanks!메이저사이트
Sun, 02 Jan 2022 05:17:07 +0800
I also believe therefore , perfectly pent post! . 메이저사이트
Wed, 16 Feb 2022 17:13:27 +0800
Seriously sturdy, magnificent, fact-filled information and facts listed here. A person's discussions Never need disappoint, and the unquestionably is valid listed within addition. You actually continually make a fun learn. Can you convey to I'm just happy?: )#) Keep current the nice reports. 안전놀이터
Tue, 04 Oct 2022 03:55:06 +0800
I’m impressed, I must say. Genuinely rarely do you encounter a weblog that’s both educative and entertaining, and let me tell you, you may have hit the nail about the head. Your concept is outstanding; ab muscles something that too few people are speaking intelligently about. I’m delighted i found this in my hunt for something about it. Laptop