none
如何去识别手悬停在屏幕上 RRS feed

  • 问题

  • 比如说手悬停在屏幕上任意位置5秒钟就发送一个数据包给指定端口?

    真心求教怎么实现!一个大学生求教。。

    2013年7月10日 3:27

答案

  • 您好,根据与您线下的交流,我简单写了个WPF的小程序,判断Kinect中骨骼追踪中手部所在的位置,然后将其映射到屏幕上,判断N秒内(程序中设置为5秒)手部位置是否发生变化,然后来开启或者重置timer控件,部分代码如下:

    [DllImport("user32.dll")]
            static extern bool SetCursorPos(int X, int Y);
            /// <summary>
            /// Active Kinect sensor
            /// </summary>
            private KinectSensor sensor;
    
            /// <summary>
            /// Bitmap that will hold color information
            /// </summary>
            private WriteableBitmap colorBitmap;
    
            /// <summary>
            /// Intermediate storage for the depth data received from the camera
            /// </summary>
            private short[] depthPixels;
    
            /// <summary>
            /// Intermediate storage for the depth data converted to color
            /// </summary>
            private byte[] colorPixels;
          
            int screenWidth = (int)SystemParameters.PrimaryScreenWidth;
            int screenHeight = (int)SystemParameters.PrimaryScreenHeight;
    
            bool handReady = false;
    
    
            private Timer timer = new Timer();
            private Point lastPoint;
            const float tolerance = 100F;
    
            /// <summary>
            /// Initializes a new instance of the MainWindow class.
            /// </summary>
            public MainWindow()
            {
                InitializeComponent();
                timer.Elapsed += timer_Elapsed;
                timer.Interval = 5000;
            }
    
            void timer_Elapsed(object sender, ElapsedEventArgs e)
            {
                //you message need to send
                MessageBox.Show("Send message");
            }
    
    
            /// <summary>
            /// Execute startup tasks
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void WindowLoaded(object sender, RoutedEventArgs e)
            {
    
                foreach (var potentialSensor in KinectSensor.KinectSensors)
                {
                    if (potentialSensor.Status == KinectStatus.Connected)
                    {
                        this.sensor = potentialSensor;
                        break;
                    }
                }
    
                if (null != this.sensor)
                {
                    // Turn on the depth stream to receive depth frames
                    this.sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
    
                    this.sensor.SkeletonStream.Enable();
    
                    // Allocate space to put the depth pixels we'll receive
                    this.depthPixels = new short[this.sensor.DepthStream.FramePixelDataLength];
    
                    // Allocate space to put the color pixels we'll create
                    this.colorPixels = new byte[this.sensor.DepthStream.FramePixelDataLength * sizeof(int)];
    
                    // This is the bitmap we'll display on-screen
                    this.colorBitmap = new WriteableBitmap(this.sensor.DepthStream.FrameWidth, this.sensor.DepthStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
    
                    // Set the image we display to point to the bitmap where we'll put the image data
                    this.imgDepth.Source = this.colorBitmap;
    
                    this.sensor.DepthStream.Range = DepthRange.Default;
    
                    this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady;
    
                    this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
    
                    // Start the sensor!
                    try
                    {
                        this.sensor.Start();
                    }
                    catch (IOException)
                    {
                        this.sensor = null;
                    }
                }
    
                if (null == this.sensor)
                {
                    MessageBox.Show("No Ready Kinect Found...Please check your device connection");
                }
            }
    
            /// <summary>
            /// Execute shutdown tasks
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                if (null != this.sensor)
                {
                    this.sensor.Stop();
                }
            }
    
            /// <summary>
            /// Event handler for Kinect sensor's SkeletonFrameReady event
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
            {
                Skeleton[] skeletons = new Skeleton[0];
    
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                {
                    if (skeletonFrame != null)
                    {
                        skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                        skeletonFrame.CopySkeletonDataTo(skeletons);
                    }
                }
    
                if (skeletons.Length != 0)
                {
                    Skeleton skel = (from s in skeletons
                                     where s.TrackingState == SkeletonTrackingState.Tracked
                                     select s).FirstOrDefault();
                    if (null == skel)
                    {
                        timer.Stop();
                        return;
                    }
    
                    if (skel.TrackingState == SkeletonTrackingState.Tracked)
                    {
                        timer.Start();
                        Joint jointHandLeft = skel.Joints[JointType.HandLeft];
                        Joint jointHandRight = skel.Joints[JointType.HandRight];
                        Joint jointShoulderCenter = skel.Joints[JointType.ShoulderCenter];
    
                        int cursorx = 0;
                        int cursory = 0;
                        //right hand
                        if (jointHandRight.Position.Z - jointShoulderCenter.Position.Z < -0.3)
                        {
                            float x = jointHandRight.Position.X - jointShoulderCenter.Position.X;//hX - sX;
                            float y = jointShoulderCenter.Position.Y - jointHandRight.Position.Y;//sY - hY;
                            handReady = true;
                            cursorx = (int)((x + 0.05) / 0.35 * screenWidth);
                            cursory = (int)(y / 0.35 * screenHeight);
                            SetCursorPos(cursorx, cursory);
                        }//left hand
                        else if (jointHandLeft.Position.Z - jointShoulderCenter.Position.Z < -0.3)
                        {
                            float x = jointHandLeft.Position.X - jointShoulderCenter.Position.X;//hX - sX;
                            float y = jointShoulderCenter.Position.Y - jointHandLeft.Position.Y;//sY - hY;
                            handReady = true;
    
                            cursorx = (int)((x + 0.3) / 0.35 * screenWidth);
                            cursory = (int)(y / 0.35 * screenHeight);
                            SetCursorPos(cursorx, cursory);
                        }
                        else
                        {
                            handReady = false;
                        }
    
                        if (handReady)
                        {
                            double distance = Math.Sqrt(Math.Pow((cursorx - lastPoint.X), 2) + Math.Pow((cursory - lastPoint.Y), 2));
                            if (distance > tolerance)
                            {
                                //mouse moved beyond tolerance - reset timer
                                timer.Stop();
                                timer.Start();
                                lastPoint = new Point(cursorx, cursory);
                            }
                        }
    
                        tbInfo.Text = "x: " + cursorx + " y:" + cursory;
                    }
                    else
                    {
                        timer.Stop();
                    }
    
                }
    
            }
    程序的代码已经通过QQ发给您了,希望有所帮助。

    2013年7月11日 16:11
    版主

全部回复

  • 您好,可以结合MouseEnter,MouseMove,MouseLeave以及一个Timer控件来实现这个功能。具体代码如下:

    private Timer timer = new Timer();
    private Point lastPoint;
    const float tolerance = 5.0F;
    bool listening = false;
    public Form1()
    {
        InitializeComponent();
        timer.Tick += new EventHandler(timer_Tick);
        timer.Interval = 5000;
    }
    
    void timer_Tick(object sender, EventArgs e)
    {
        //TODO:Send something to the assigned port;
    }
    
    private void Form1_MouseLeave(object sender, EventArgs e)
    {
        timer.Stop();
        listening = false; //stop listening
    }
    
    private void Form1_MouseEnter(object sender, EventArgs e)
    {
        timer.Start();
        listening = true; //listen to MouseMove events
    }
    
    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        if (listening)
        {
            float distance=Math.Sqrt(Math.Pow((e.Location.X-lastPoint.X),2)+Math.Pow ((e.Location.Y-lastPoint.Y),2));
            if (distance > tolerance)
            {
                //mouse moved beyond tolerance - reset timer
                timer.Stop();
                timer.Start();
                lastPoint = e.Location;
            }
        }
    }

    您将需要做的事情放在timer控件的ticker事件中即可。

       另外,在Kinect中,更友好的做法是似乎是使用Kinect Hover Button和Kinect Magic Button,就是在屏幕上放置一个按钮,当用户的手放到该按钮上时,在N秒后出发某一事件,具体的做法您可以查看这篇文章,http://www.cnblogs.com/yangecnu/archive/2012/04/28/KinectSDK_GesturesDetection_part2_BasicGesturesDetection.html

        希望对您有所帮助。

    2013年7月10日 9:58
    版主
  • 您好,可以结合MouseEnter,MouseMove,MouseLeave以及一个Timer控件来实现这个功能。具体代码如下:

    private Timer timer = new Timer();
    private Point lastPoint;
    const float tolerance = 5.0F;
    bool listening = false;
    public Form1()
    {
        InitializeComponent();
        timer.Tick += new EventHandler(timer_Tick);
        timer.Interval = 5000;
    }
    
    void timer_Tick(object sender, EventArgs e)
    {
        //TODO:Send something to the assigned port;
    }
    
    private void Form1_MouseLeave(object sender, EventArgs e)
    {
        timer.Stop();
        listening = false; //stop listening
    }
    
    private void Form1_MouseEnter(object sender, EventArgs e)
    {
        timer.Start();
        listening = true; //listen to MouseMove events
    }
    
    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        if (listening)
        {
            float distance=Math.Sqrt(Math.Pow((e.Location.X-lastPoint.X),2)+Math.Pow ((e.Location.Y-lastPoint.Y),2));
            if (distance > tolerance)
            {
                //mouse moved beyond tolerance - reset timer
                timer.Stop();
                timer.Start();
                lastPoint = e.Location;
            }
        }
    }

    您将需要做的事情放在timer控件的ticker事件中即可。

         希望对您有所帮助。

    您真是个热心肠的人,我的程序的意思是能在WPF应用程序中实现,并且将这个程序最小化了也能用,如何来实现呢?您提供的只是在这个应用程序窗体上能用,哪如果我将这个窗体程序最小化了就不行了,能否在提供下思路和代码呢?真心谢谢您!

    另外您是否能打包源程序给我参考一下呢??大学生菜鸟求救。我的邮箱mingzhengjia@gmail.com  谢谢您了,而且我发现我提的问题您总是热心的回答。再次表示感谢





    • 已编辑 Magic Lamp 2013年7月11日 5:54 写的不够清楚
    2013年7月11日 3:17
  • 如果要在最小化的情况下 监听鼠标事件的话,可能需要注册全局的鼠标事件,这里有一篇文章讲解了如何在C#中注册全局的鼠标事件,您可以下载Demo下来稍加改造即可。http://www.dotblogs.com.tw/optimist9266/archive/2011/06/07/27309.aspx

    另外,如果结合Kinect使用的话,可以看看http://kinectmouse.codeplex.com/  这个开源项目。

    2013年7月11日 6:24
    版主
  • 您好,根据与您线下的交流,我简单写了个WPF的小程序,判断Kinect中骨骼追踪中手部所在的位置,然后将其映射到屏幕上,判断N秒内(程序中设置为5秒)手部位置是否发生变化,然后来开启或者重置timer控件,部分代码如下:

    [DllImport("user32.dll")]
            static extern bool SetCursorPos(int X, int Y);
            /// <summary>
            /// Active Kinect sensor
            /// </summary>
            private KinectSensor sensor;
    
            /// <summary>
            /// Bitmap that will hold color information
            /// </summary>
            private WriteableBitmap colorBitmap;
    
            /// <summary>
            /// Intermediate storage for the depth data received from the camera
            /// </summary>
            private short[] depthPixels;
    
            /// <summary>
            /// Intermediate storage for the depth data converted to color
            /// </summary>
            private byte[] colorPixels;
          
            int screenWidth = (int)SystemParameters.PrimaryScreenWidth;
            int screenHeight = (int)SystemParameters.PrimaryScreenHeight;
    
            bool handReady = false;
    
    
            private Timer timer = new Timer();
            private Point lastPoint;
            const float tolerance = 100F;
    
            /// <summary>
            /// Initializes a new instance of the MainWindow class.
            /// </summary>
            public MainWindow()
            {
                InitializeComponent();
                timer.Elapsed += timer_Elapsed;
                timer.Interval = 5000;
            }
    
            void timer_Elapsed(object sender, ElapsedEventArgs e)
            {
                //you message need to send
                MessageBox.Show("Send message");
            }
    
    
            /// <summary>
            /// Execute startup tasks
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void WindowLoaded(object sender, RoutedEventArgs e)
            {
    
                foreach (var potentialSensor in KinectSensor.KinectSensors)
                {
                    if (potentialSensor.Status == KinectStatus.Connected)
                    {
                        this.sensor = potentialSensor;
                        break;
                    }
                }
    
                if (null != this.sensor)
                {
                    // Turn on the depth stream to receive depth frames
                    this.sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
    
                    this.sensor.SkeletonStream.Enable();
    
                    // Allocate space to put the depth pixels we'll receive
                    this.depthPixels = new short[this.sensor.DepthStream.FramePixelDataLength];
    
                    // Allocate space to put the color pixels we'll create
                    this.colorPixels = new byte[this.sensor.DepthStream.FramePixelDataLength * sizeof(int)];
    
                    // This is the bitmap we'll display on-screen
                    this.colorBitmap = new WriteableBitmap(this.sensor.DepthStream.FrameWidth, this.sensor.DepthStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
    
                    // Set the image we display to point to the bitmap where we'll put the image data
                    this.imgDepth.Source = this.colorBitmap;
    
                    this.sensor.DepthStream.Range = DepthRange.Default;
    
                    this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady;
    
                    this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
    
                    // Start the sensor!
                    try
                    {
                        this.sensor.Start();
                    }
                    catch (IOException)
                    {
                        this.sensor = null;
                    }
                }
    
                if (null == this.sensor)
                {
                    MessageBox.Show("No Ready Kinect Found...Please check your device connection");
                }
            }
    
            /// <summary>
            /// Execute shutdown tasks
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                if (null != this.sensor)
                {
                    this.sensor.Stop();
                }
            }
    
            /// <summary>
            /// Event handler for Kinect sensor's SkeletonFrameReady event
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
            {
                Skeleton[] skeletons = new Skeleton[0];
    
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                {
                    if (skeletonFrame != null)
                    {
                        skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                        skeletonFrame.CopySkeletonDataTo(skeletons);
                    }
                }
    
                if (skeletons.Length != 0)
                {
                    Skeleton skel = (from s in skeletons
                                     where s.TrackingState == SkeletonTrackingState.Tracked
                                     select s).FirstOrDefault();
                    if (null == skel)
                    {
                        timer.Stop();
                        return;
                    }
    
                    if (skel.TrackingState == SkeletonTrackingState.Tracked)
                    {
                        timer.Start();
                        Joint jointHandLeft = skel.Joints[JointType.HandLeft];
                        Joint jointHandRight = skel.Joints[JointType.HandRight];
                        Joint jointShoulderCenter = skel.Joints[JointType.ShoulderCenter];
    
                        int cursorx = 0;
                        int cursory = 0;
                        //right hand
                        if (jointHandRight.Position.Z - jointShoulderCenter.Position.Z < -0.3)
                        {
                            float x = jointHandRight.Position.X - jointShoulderCenter.Position.X;//hX - sX;
                            float y = jointShoulderCenter.Position.Y - jointHandRight.Position.Y;//sY - hY;
                            handReady = true;
                            cursorx = (int)((x + 0.05) / 0.35 * screenWidth);
                            cursory = (int)(y / 0.35 * screenHeight);
                            SetCursorPos(cursorx, cursory);
                        }//left hand
                        else if (jointHandLeft.Position.Z - jointShoulderCenter.Position.Z < -0.3)
                        {
                            float x = jointHandLeft.Position.X - jointShoulderCenter.Position.X;//hX - sX;
                            float y = jointShoulderCenter.Position.Y - jointHandLeft.Position.Y;//sY - hY;
                            handReady = true;
    
                            cursorx = (int)((x + 0.3) / 0.35 * screenWidth);
                            cursory = (int)(y / 0.35 * screenHeight);
                            SetCursorPos(cursorx, cursory);
                        }
                        else
                        {
                            handReady = false;
                        }
    
                        if (handReady)
                        {
                            double distance = Math.Sqrt(Math.Pow((cursorx - lastPoint.X), 2) + Math.Pow((cursory - lastPoint.Y), 2));
                            if (distance > tolerance)
                            {
                                //mouse moved beyond tolerance - reset timer
                                timer.Stop();
                                timer.Start();
                                lastPoint = new Point(cursorx, cursory);
                            }
                        }
    
                        tbInfo.Text = "x: " + cursorx + " y:" + cursory;
                    }
                    else
                    {
                        timer.Stop();
                    }
    
                }
    
            }
    程序的代码已经通过QQ发给您了,希望有所帮助。

    2013年7月11日 16:11
    版主
  • 您好,根据与您线下的交流,我简单写了个WPF的小程序,判断Kinect中骨骼追踪中手部所在的位置,然后将其映射到屏幕上,判断N秒内(程序中设置为5秒)手部位置是否发生变化,然后来开启或者重置timer控件,部分代码如下:

    [DllImport("user32.dll")]
            static extern bool SetCursorPos(int X, int Y);
            /// <summary>
            /// Active Kinect sensor
            /// </summary>
            private KinectSensor sensor;
    
            /// <summary>
            /// Bitmap that will hold color information
            /// </summary>
            private WriteableBitmap colorBitmap;
    
            /// <summary>
            /// Intermediate storage for the depth data received from the camera
            /// </summary>
            private short[] depthPixels;
    
            /// <summary>
            /// Intermediate storage for the depth data converted to color
            /// </summary>
            private byte[] colorPixels;
          
            int screenWidth = (int)SystemParameters.PrimaryScreenWidth;
            int screenHeight = (int)SystemParameters.PrimaryScreenHeight;
    
            bool handReady = false;
    
    
            private Timer timer = new Timer();
            private Point lastPoint;
            const float tolerance = 100F;
    
            /// <summary>
            /// Initializes a new instance of the MainWindow class.
            /// </summary>
            public MainWindow()
            {
                InitializeComponent();
                timer.Elapsed += timer_Elapsed;
                timer.Interval = 5000;
            }
    
            void timer_Elapsed(object sender, ElapsedEventArgs e)
            {
                //you message need to send
                MessageBox.Show("Send message");
            }
    
    
            /// <summary>
            /// Execute startup tasks
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void WindowLoaded(object sender, RoutedEventArgs e)
            {
    
                foreach (var potentialSensor in KinectSensor.KinectSensors)
                {
                    if (potentialSensor.Status == KinectStatus.Connected)
                    {
                        this.sensor = potentialSensor;
                        break;
                    }
                }
    
                if (null != this.sensor)
                {
                    // Turn on the depth stream to receive depth frames
                    this.sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
    
                    this.sensor.SkeletonStream.Enable();
    
                    // Allocate space to put the depth pixels we'll receive
                    this.depthPixels = new short[this.sensor.DepthStream.FramePixelDataLength];
    
                    // Allocate space to put the color pixels we'll create
                    this.colorPixels = new byte[this.sensor.DepthStream.FramePixelDataLength * sizeof(int)];
    
                    // This is the bitmap we'll display on-screen
                    this.colorBitmap = new WriteableBitmap(this.sensor.DepthStream.FrameWidth, this.sensor.DepthStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
    
                    // Set the image we display to point to the bitmap where we'll put the image data
                    this.imgDepth.Source = this.colorBitmap;
    
                    this.sensor.DepthStream.Range = DepthRange.Default;
    
                    this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady;
    
                    this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
    
                    // Start the sensor!
                    try
                    {
                        this.sensor.Start();
                    }
                    catch (IOException)
                    {
                        this.sensor = null;
                    }
                }
    
                if (null == this.sensor)
                {
                    MessageBox.Show("No Ready Kinect Found...Please check your device connection");
                }
            }
    
            /// <summary>
            /// Execute shutdown tasks
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                if (null != this.sensor)
                {
                    this.sensor.Stop();
                }
            }
    
            /// <summary>
            /// Event handler for Kinect sensor's SkeletonFrameReady event
            /// </summary>
            /// <param name="sender">object sending the event</param>
            /// <param name="e">event arguments</param>
            private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
            {
                Skeleton[] skeletons = new Skeleton[0];
    
                using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                {
                    if (skeletonFrame != null)
                    {
                        skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                        skeletonFrame.CopySkeletonDataTo(skeletons);
                    }
                }
    
                if (skeletons.Length != 0)
                {
                    Skeleton skel = (from s in skeletons
                                     where s.TrackingState == SkeletonTrackingState.Tracked
                                     select s).FirstOrDefault();
                    if (null == skel)
                    {
                        timer.Stop();
                        return;
                    }
    
                    if (skel.TrackingState == SkeletonTrackingState.Tracked)
                    {
                        timer.Start();
                        Joint jointHandLeft = skel.Joints[JointType.HandLeft];
                        Joint jointHandRight = skel.Joints[JointType.HandRight];
                        Joint jointShoulderCenter = skel.Joints[JointType.ShoulderCenter];
    
                        int cursorx = 0;
                        int cursory = 0;
                        //right hand
                        if (jointHandRight.Position.Z - jointShoulderCenter.Position.Z < -0.3)
                        {
                            float x = jointHandRight.Position.X - jointShoulderCenter.Position.X;//hX - sX;
                            float y = jointShoulderCenter.Position.Y - jointHandRight.Position.Y;//sY - hY;
                            handReady = true;
                            cursorx = (int)((x + 0.05) / 0.35 * screenWidth);
                            cursory = (int)(y / 0.35 * screenHeight);
                            SetCursorPos(cursorx, cursory);
                        }//left hand
                        else if (jointHandLeft.Position.Z - jointShoulderCenter.Position.Z < -0.3)
                        {
                            float x = jointHandLeft.Position.X - jointShoulderCenter.Position.X;//hX - sX;
                            float y = jointShoulderCenter.Position.Y - jointHandLeft.Position.Y;//sY - hY;
                            handReady = true;
    
                            cursorx = (int)((x + 0.3) / 0.35 * screenWidth);
                            cursory = (int)(y / 0.35 * screenHeight);
                            SetCursorPos(cursorx, cursory);
                        }
                        else
                        {
                            handReady = false;
                        }
    
                        if (handReady)
                        {
                            double distance = Math.Sqrt(Math.Pow((cursorx - lastPoint.X), 2) + Math.Pow((cursory - lastPoint.Y), 2));
                            if (distance > tolerance)
                            {
                                //mouse moved beyond tolerance - reset timer
                                timer.Stop();
                                timer.Start();
                                lastPoint = new Point(cursorx, cursory);
                            }
                        }
    
                        tbInfo.Text = "x: " + cursorx + " y:" + cursory;
                    }
                    else
                    {
                        timer.Stop();
                    }
    
                }
    
            }
    程序的代码已经通过QQ发给您了,希望有所帮助。

    自己改了改可以用了,谢谢杨哥,遇到不懂的问题希望您能帮我解决下,,谢谢杨哥,您是热心肠的人
    2013年7月12日 5:23