问个小题,
1.当光标在屏幕上移动时
怎么能得到光标的坐标
2.怎么得到光标下面控件的句柄?

解决方案 »

  1.   

    1.see here:http://blog.csdn.net/sohighthesky/archive/2009/04/15/4074757.aspx2.看看spy++的源码吧
      

  2.   

       private void Form1_MouseMove(object sender, MouseEventArgs e)
            {
             label1.Text=string.Format("哈哈捕捉到鼠标位置了!{0},{1}", e.X, e.Y);
        
            }
      

  3.   

    有win32ApI看以,
    [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
            private static extern int GetDC(int hwnd); 
            [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] //确定坐标
            private static extern int ReleaseDC(int hwnd, int hdc);
            POINTAPI P; //确定坐标
            [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
            private static extern int ScreenToClient(int hwnd, ref POINTAPI lpPoint);
            [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]//获取窗体句柄
            private static extern int WindowFromPoint(int xPoint, int yPoint);