The mouse_event function synthesizes mouse motion and button clicks. Windows NT/2000/XP: This function has been superseded. Use SendInput instead.
改成这样看看
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTDOWN,2000,100,0,0); 
mouse_event(MOUSEEVENTF_LEFTUP|MOUSEEVENTF_ABSOLUTE,2000,100,0,0); 

解决方案 »

  1.   

    On_danji这函数名真叫个好啊。楼主要模拟,为何不做个定时器让它随机模拟,鼠标点来点去的,不好说啊。
      

  2.   

    要先SetCursorPos(2000, 100);
    再mouse_event
      

  3.   

    按照Snow_Ice11111所说,解决了我的问题,多谢!
    但是,我发现如果不调用SetCursorPos(2000,   100); ,mouse_event就不好使,比如
    void CTestDlg::On_danji() 
    {
    SetCursorPos(550,500);
    n=0;
    SetTimer(1,500,NULL);
    }
    void CTestDlg::OnTimer(UINT nIDEvent) 
    {
    // TODO: Add your message handler code here and/or call default
    n++;
    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN,50*n,0,0,0);
    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP,50*n,0,0,0); if(n>10) { KillTimer(1); }
    CDialog::OnTimer(nIDEvent);
    }
    运行结果,鼠标根本不动,请问是什么原因呢?
      

  4.   

    每次使用前都SetCurPos人工设置一个鼠标位置。mouse_event函数旧了点,我们还是听从MS的建议吧:Windows NT/2000/XP: This function has been superseded. Use SendInput instead.
      

  5.   

    SendInput怎么用啊,网上关于它的资料很少啊