如果用WH_GETMESSAGE或者用WH_MOUSE钩子好想只能捕捉鼠标在客户区(Client)上的坐标和单击等消息,一旦鼠标移出了客户区,例如鼠标在窗口标题栏或者菜单栏还有Windows系统任务栏的时候,就不能捕捉到鼠标的任何消息了。
请问有什么办法可以捕捉到鼠标在屏幕上任意一点的坐标和单击等消息?
我现在想在整个屏幕范围内,把鼠标的所有动作记录到脚本文件,然后根据该脚本回放鼠标动作

解决方案 »

  1.   

    不用那么复杂吧,api就可以解决拉GetCursorPos
      

  2.   

    GetCursorPos Function  --------------------------------------------------------------------------------The GetCursorPos function retrieves the cursor's position, in screen coordinates. SyntaxBOOL GetCursorPos(          LPPOINT lpPoint
    );
    ParameterslpPoint
    [out] Pointer to a POINT structure that receives the screen coordinates of the cursor. 
    Return ValueIf the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.ResThe cursor position is always specified in screen coordinates and is not affected by the mapping mode of the window that contains the cursor. The calling process must have WINSTA_READATTRIBUTES access to the window station. ExampleFor an example, see Using the Keyboard to Move the Cursor.Function InformationHeader Declared in Winuser.h, include Windows.h 
    Import library User32.lib 
    Minimum operating systems Windows 95, Windows NT 3.1 See Also
      

  3.   

    Void CTestView::OnMouseMove(UINT nFlags,Cpoint point){CclientDC dc(this);//建立设备文本OnPrepareDC(&dc,NULL);//设备映射处理dc.DPtoLP(&point);//鼠标指针转换char text[128];CstatusBar *pStatus=(CstatusBar *)AfxGetApp()->m_pMainWnd->GetDescendanWindow(AFX_IDW_STATUS_BAR);//取得窗口指针If(pStatus){//如果存在显示鼠标坐标Sprintf(text,”X坐标=%4d,Y坐标=%4d”,point.x,point.y);pStatus->SetPaneText(0,text);}CscrollView::OnMouseMove(nFlags,point); }