这是我写QQ连连看代码头文件,都是关键方法,只要知道调用就可以了

#include "stdafx.h"

HWND hWnd=NULL;
BYTE buffer[11][19];
bool FindLLKWindow()
{
    hWnd=::FindWindow(NULL,"QQ游戏 - 连连看角色版");
if(hWnd==NULL)
    {
return false;
    }
return true;
}
bool ReadChessboard(CString* resultStr)
{
// TODO: Add your control notification handler code here
    FindLLKWindow();
    DWORD processID;
    ::GetWindowThreadProcessId(hWnd,&processID);
    HANDLE processHandle=::OpenProcess(PROCESS_ALL_ACCESS,false,processID);
if(processHandle==NULL)
    {
return false;
    }
    DWORD readNum;

    ::ReadProcessMemory(processHandle,(LPCVOID)0x0012A47C,buffer,11*19,&readNum);
char tempChar[2];
    CString showString;
for(int i=0;i<11;i++)
    {
for(int j=0;j<19;j++)
        {
            itoa(buffer[i][j],tempChar,16);
if(buffer[i][j]<=0xF)
            {
                showString+="0";
            }
            showString+=tempChar;
            showString+=" ";
        }
        showString+="\r\n";
    }
*resultStr=showString;
return true;
}
bool SelectChess(int x,int y)
{
if(hWnd==NULL)FindLLKWindow();
    SendMessage(hWnd,WM_LBUTTONDOWN,1,(y<<16)+x);
    SendMessage(hWnd,WM_LBUTTONUP,1,(y<<16)+x);
return true;
}
bool LinkPair(int x1,int y1,int x2,int y2,int *xxx);
CString ClearPair()
{
//判定棋字相同
    CString temp;
    ReadChessboard(&temp);
    CString str;
int xxx;
for(int i=0;i<11;i++)
    {
for(int j=0;j<19;j++)
        {
for(int k=0;k<11;k++)
            {
for(int h=0;h<19;h++)
                {
if(buffer[i][j]>0 && buffer[i][j]==buffer[k][h] && (i!=k || j!=h))
                    {
if(LinkPair(j,i,h,k,&xxx))
                        {
                            str.Format("%d*%d==%d*%d,point=%d",j+1,i+1,h+1,k+1,xxx);
                            SelectChess(28+j*31,196+i*35);
//Sleep(100);
                            SelectChess(28+h*31,196+k*35);
return str;
                        }                        
                    }
                }
            }
        }
    }
return "";

}
//确定棋子在三折线内可连接
bool LinkPair(int x1,int y1,int x2,int y2,int *xxx)
{
    POINT p1,p2;
bool line1=true,line2=true,line3=true;
bool results=true;
if(y1==y2)
    {
for(int v1=min(x1,x2)+1;v1<max(x1,x2);v1++)
        {
if(buffer[y1][v1]!=0)
            {
                results=false;
break;
            }
        }
if(results)
        {
*xxx=-1;
return true;
        }        
    }
    results=true;
if(x1==x2)
    {
for(int h1=min(y1,y2)+1;h1<max(y1,y2);h1++)
        {
if(buffer[h1][x1]!=0)
            {
                results=false;
break;
            }
        }
if(results)
        {
*xxx=-1;
return true;
        }
    }
for(int i=0;i<19;i++)
    {
for(int v1=min(i,x1);v1<=max(i,x1);v1++)
        {
if(buffer[y1][v1]!=0 && v1!=x1)
            {
                line1=false;
break;
            }
else line1=true;
        }
if(line1)
        {
for(int h=min(y1,y2)+1;h<max(y1,y2);h++)
            {
if(buffer[h][i]!=0)
                {
                    line2=false;
break;
                }
else line2=true;
            }
if(line2)
            {            
for(int v2=min(i,x2);v2<=max(x2,i);v2++)
                {
if(buffer[y2][v2]!=0 && v2!=x2)
                    {
                        line3=false;
break;
                    }
else line3=true;
                }
            }
        }
if(line1 && line2 && line3)
        {
*xxx=i;
return true;
        }        
    }
    line1=true,line2=true,line3=true;
for(int yy=0;yy<11;yy++)
    {
for(int h1=min(yy,y1);h1<=max(yy,y1);h1++)
        {
if(buffer[h1][x1]!=0 && h1!=y1)
            {
                line1=false;
break;
            }
else line1=true;
        }
if(line1)
        {
for(int vv=min(x1,x2)+1;vv<max(x1,x2);vv++)
            {
if(buffer[yy][vv]!=0)
                {
                    line2=false;
break;
                }
else line2=true;
            }
if(line2)
            {            
for(int h2=min(yy,y2);h2<=max(yy,y2);h2++)
                {
if(buffer[h2][x2]!=0 && h2!=y2)
                    {
                        line3=false;
break;
                    }
else line3=true;
                }
            }
        }
if(line1&&line2&&line3)
        {
*xxx=yy;
return true;
        }
    }
return false;
}