VC++模拟一次鼠标点击返回原位置

 HWND h;
 RECT r1;
 POINT p;//x,y
void ONCE()
{
    h=::FindWindow(NULL,"biaoti");
    ::GetWindowRect(h,&r1); 
 
    //保存当前鼠标指针
    //取得当前鼠标位置
    GetCursorPos(&p);
    //设置鼠标指针位置  取坐标:x=273;y=273 //lparam 0x01110111
    SetCursorPos(273+r1.left,273+r1.top);
    //按下
    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);
}

 

posted @ 2015-06-06 11:33  银月星  阅读(1202)  评论(0编辑  收藏  举报