[外挂2] 鼠标单击事件

 

 

a、鼠拟鼠标单击mouse_event

b、鼠标指针移动还原

 

HWND gameh;//游戏窗口句柄
RECT r1;//RECT结构表示一个矩形区域
POINT p;//x,y
void CFewDlg::OnStartGame()
{
    gameh=::FindWindow(NULL,"井字棋");
    ::GetWindowRect(gameh,&r1);

    GetCursorPos(&p);//保存当前鼠标指针 //取得当前鼠标位置
    SetCursorPos(100+r1.left,100+r1.top);//当前窗口坐标+开局按钮坐标

    this->m_x=r1.left;
    this->m_y=r1.top;
    UpdateData(false);//显示到编辑框

    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//鼠标在当前位置按下
    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//鼠标在当前位置抬起
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

    Sleep(200);//过一段时间 再执行后边的代码
    SetCursorPos(p.x,p.y); //还原鼠标位置
}

void CFewDlg::OnButton1() 
{
    OnStartGame();
}

MFC框架构造请看[外挂1]

posted @ 2014-03-25 20:38  beautifulzzzz  阅读(895)  评论(0编辑  收藏  举报