软件制作:QQGamePlug Lianliankan Function

class CChessPoint 

{

public:

       POINT p;

       POINT up;

       POINT down;

       POINT left;

       POINT right;

       CChessPoint(POINT pxy);  //构造函数

       virtual ~CChessPoint();

 

};

 #endif // !defined(AFX_CHESSPOINT_H__6D9CA888_80A2_4304_A4D8_A60C87548185__INCLUDED_)

CChessPoint::CChessPoint(POINT pxy)

{

       up=pxy;down=pxy;left=pxy;right=pxy;

       p=pxy;

       up.y=pxy.y-1;

       down.y=pxy.y+1;

       left.x=pxy.x-1;

       right.x=pxy.x+1;

}

CChessPoint::~CChessPoint()

{}

const PCHARgameCaption="QQ游戏 - 连连看角色版";

 HWNDgameh;//游戏窗口句柄

 RECT r1;  //游戏窗体信息

 POINT p;//x,y当前鼠标的位置

boolgametop=false;

void StartGame()

{

       // TODO: Add your control notification handler code here

       //获取游戏窗口句柄 Handle

/*

       HWND FindWindow(        

           LPCTSTR lpClassName,   //窗口类名

              LPCTSTR lpWindowName   //窗口标题

              );

*/

       gameh=::FindWindow(NULL,gameCaption);

       ::GetWindowRect(gameh,&r1);//把当前游戏窗体信息给r1

    /*

       this->m_x=r1.left;this->m_y=r1.top;

       //更新窗体坐标

       UpdateData(false);

       */

       GetCursorPos(&p);

       //设置鼠标指针位置  取开局所在坐标:x=658 ,y=571  //IParam=x023B0292

       SetCursorPos(658+r1.left,571+r1.top);

      //鼠标在当前位置按下

       mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);

       //

       Sleep(100);

       //鼠标在当前位置抬起

       mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

       SetCursorPos(p.x,p.y);

}

 

 

void StartGameBySoft()

{

       // TODO: Add your control notification handler code here

       //获取游戏窗口句柄 Handle

/*

SendMessage(hwnd,WM_LBUTTOMDOWN,0,YX);//hwnd=FindWindow(NULL,游戏标题);

SendMessage(hwnd,WM_LBUTTOMUP,0,YX);  //PostMessage/mouse_event

*/

       int   x=22,y=187;

       gameh=::FindWindow(NULL,gameCaption);

       int lparam;

       lparam=(y<<16)+x;//表示指定格

       ::SendMessage(gameh,WM_LBUTTONDOWN,0,lparam);//鼠标软模拟

       ::SendMessage(gameh,WM_LBUTTONUP,0,lparam);  //

}

 void ReadSeatNum(LPCVOIDlpBaseAddress, LPVOIDlpBuffer,int numByte)

{

   //获取座位号

       /*

       1FindWindow               //获取窗口句柄

       2GetWindowThreadProcessId //获取窗口进程ID

       3OpenProcess              //打开指定进程

       4ReadProcessMemory        //读指定进程内存数据

       游戏进程名:KYODAI~1.EXE

       游戏窗口标题:"QQ游戏 - 连连看角色版"

       HWND FindWindow(

       LPCTSTR lpClassName,  // NULL 忽略

       LPCTSTR lpWindowName  // 窗口标题

       );

      

         BOOL ReadProcessMemory(

         HANDLE hProcess,  // 进程句柄

         LPCVOID lpBaseAddress,

         // 基址0x00B8D8E0

         LPVOID lpBuffer,  // 存放数据缓冲区

         DWORD nSize,      // 要读取数据的字节数

         LPDWORD lpNumberOfBytesRead

         // 实际读取的字节数

         );

       */

    gameh=::FindWindow(NULL,gameCaption);

       DWORD  processId;

       ::GetWindowThreadProcessId(gameh,&processId);

       HANDLEprocessHandle=::OpenProcess(PROCESS_ALL_ACCESS,false,processId);

       DWORDbyread;

    ::ReadProcessMemory(processHandle,lpBaseAddress,lpBuffer,numByte,&byread);

}

 

bytechessdata[11][19];//a[y][x]

void updatdChess() //更新棋盘数据至 chessdata

{ 

       LPCVOIDpbase=(LPCVOID)0x0012A480;

    LPVOID   nbuffer=(LPVOID)&chessdata;

       ReadSeatNum(pbase,nbuffer,11*19);

}    

boolCheckLine(POINT p1,POINT p2)

{

 //

};

boolCheck2p(POINT a,POINT b)

{

 //

}

boolClick2p(POINT p1,POINT p2)

{

  //

}

boolClearPiar() //消除一对棋子

{   

       //

}

VOIDCALLBACKplayproc(

                                      HWNDhwnd,     // handle of window for timer messages

                                      UINTuMsg,     // WM_TIMER message

                                      UINTidEvent,  // timer identifier

                                      DWORDdwTime   // current system time

                                      )

{

      ClearPiar();

}

/////////////////////////////////////////////////////////////////////////////////////////////////

VOIDCALLBACKstrartproc(

                                           HWNDhwnd,     // handle of window for timer messages

                                           UINTuMsg,     // WM_TIMER message

                                           UINTidEvent,  // timer identifier

                                           DWORDdwTime   // current system time

                                           )

{ 

       HWNDgameh=::FindWindow(NULL,gameCaption);

       //AfxMessageBox("Findwindow");

       if (gameh==0) { return;} //没有找到游戏窗口

       //让游戏窗口置顶

       if (gametop)

       {

              SetWindowPos(gameh,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);

       }    

       else

       {

              SetWindowPos(gameh,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);

       }

        DWORDpid;

       ::GetWindowThreadProcessId(gameh,&pid);

    long flag,byReadSize;

    HANDLEhp=OpenProcess(PROCESS_ALL_ACCESS,false,pid);

       ::ReadProcessMemory(hp,(LPCVOID)(0x01CF02A0),(LPVOID)(&flag),4,(LPDWORD) (&byReadSize));

       if (byReadSize==0) {AfxMessageBox("未成功读出数据");}

       if ((flag==0)&&(byReadSize>0)) { StartGame();} //自动开局

} 

 byteacode[6]={0x90,0x90,0x90,0x90,0x90,0x90};

//byte oldcode[6]={0x90,0x90,0x90,0x90,0x90,0x90};

boolClearCode()

{

       HWNDgameh=::FindWindow(NULL,gameCaption);

       //AfxMessageBox("Findwindow");

       if (gameh==0) { return false;} //没有找到游戏窗口

       DWORDpid;

       ::GetWindowThreadProcessId(gameh,&pid);

       long byWriteSize;

       HANDLEhp=OpenProcess(PROCESS_ALL_ACCESS,false,pid);

       WriteProcessMemory(hp,(LPVOID )(0x00426526),(LPVOID)(acode),6,(LPDWORD) (&byWriteSize));

       return true;

}

int ReadChessNum() //更新棋盘数据至 chessdata

{

       // TODO: Add your control notification handler code here

       //获取窗口句柄

       HWNDgameh=::FindWindow(NULL,gameCaption);

       //获取窗口进程ID

       DWORDprocessid;

       ::GetWindowThreadProcessId(gameh,&processid);

       //打开指定进程

       HANDLEprocessH=::OpenProcess(PROCESS_ALL_ACCESS,false,processid);

       //读指定进程内存数据

    DWORDbyread;

       LPCVOIDpbase=(LPCVOID)0x001163B0 ; //棋子数据基址

       int ChessNum;

       LPVOID  nbuffer=(LPVOID)&ChessNum;    //存放棋子数据

       ::ReadProcessMemory(processH,pbase,nbuffer,4,&byread);

       return ChessNum;

}

原文地址:https://www.cnblogs.com/Gemgin/p/3136259.html