码迷,mamicode.com
首页 > Windows程序 > 详细

windows鼠标消息处理

时间:2015-06-06 00:21:26      阅读:334      评论:0      收藏:0      [点我收藏+]

标签:

1、鼠标坐标问题

 BOOL GetWindowRect(

   HWND hWnd,
    LPRECT lpRect
 );

  RECT x;//定义一个二维数组x

  ::GetWindowRect(hwnd,&x);

 

  POINT P;//x,y  RECT型 X 的指针

  GetCursorPos(&p);          //取当前鼠标坐标指针

  SetCursorPos(x+r1.left,y+r1.top);  //设置下一步鼠标坐标指针

  SetCursorPos(p.x,p.y);        //还原鼠标坐标

 

2、模拟鼠标消息


                LRESULT SendMessage(
  HWND hWnd,
  UINT Msg,
  WPARAM wParam,
  LPARAM lParam
); 

int x=?,y=?;

                              //y<<16)+x=lParam

                              //lParam可由SPY++拦截获取,亦可计算

                              //eg.x=655;y=577 lparam 0x0241028f

                              //      0x 0172 01f3

                              //     370   499

左键单击模拟:

  SendMessage(hwnd,WM_LBUTTONDOWN,0,(y<<16)+x);


  SendMessage(hwnd,WM_LBUTTONUP,0,(y<<16)+x); 

 左键双击模拟:

  SendMessage(hwnd,WM_LBUTTONDBLCLK,0,(y<<16)+x); 

 

右键单击模拟:

  SendMessage(hwnd,WM_RBUTTONDOWN,0,(y<<16)+x);


  SendMessage(hwnd,WM_RBUTTONUP,0,(y<<16)+x); 

右键双击模拟:

  SendMessage(hwnd,WM_RBUTTONDBLCLK,0,(y<<16)+x); 

 

2、鼠标事件 

 

VOID mouse_event(
  DWORD dwFlags, 
  DWORD dx, 
  DWORD dy, 
  DWORD dwData, 
  DWORD dwExtraInfo
);


左键单击消息:
  mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);         //第一个参数位 鼠标操作状态


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

左键双击消息:

  mouse_event(_RBUTTONDBLCLK,0,0,0,0); 

 

 

右键单击消息
  mouse_event(MOUSEEVENTF_REFTUP,0,0,0,0); 


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

 

 

右键双击消息:
  mouse_event(   ,0,0,0,0);   

 

windows鼠标消息处理

标签:

原文地址:http://www.cnblogs.com/yyx001000000001010101100101/p/4555763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!