Click here to Skip to main content
16,020,188 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
Hi Coders!

I've a dynamically generated points (x,y) and want to know how do I write a mouse handler function to pass this point to system wide mouse event to set the cursor location to this point.

The function that generates dynamic point is:



public void getpoint()
{
......
....
for (int i = 0; i < eyes.Total; i++)
                        {
                            CvRect r = eyes[i].Value.Rect;
                            CvPoint center = new CvPoint
                            {
                                X = Cv.Round((r.X + r.Width * 0.45) * Scale),
                                Y = Cv.Round((r.Y + r.Height * 0.45) * Scale)
                            };
                            cursorpos = center;
}
}


cursorpos stores the value of (X,Y) and its global. The function taht returns this value is
SQL
public CvPoint GetCursorPos()
        {
            return cursorpos;
        }

and I'm calling it as
C#
private void BtnPowerUrEyes_Click(object sender, EventArgs e)
        {
                CvPoint newcurpos = pupilobj.GetCursorPos();
                int x = newcurpos.X;
                int y = newcurpos.Y;
                Cursor.Position = new Point(x , y);
        }


But the cursor position is not changing dynamically :(
I know I've to call GetCorsprPos() in a loop but if I do that it hangs :(

Thanks for the help in advance!
Posted
Updated 20-May-11 21:31pm
v4

Hi,

I think you can write below code to set cursor position of mouse.

Say,
Cursor.Position = new Point(x, y);

Simple, Cursor includes name spaces System.Windows.Forms.

Thanks :)

I hope, this will help you
 
Share this answer
 
v2
Comments
AmarjeetAlien 21-May-11 3:04am    
Thanks for the reply. I have updated the question. Please have a look.
Hope this[^] might help you.
 
Share this answer
 
Comments
AmarjeetAlien 21-May-11 3:04am    
Thanks for the reply. I have updated the question. Please have a look.
Kribz 27-Jun-13 14:24pm    
Hi AmarjeetAlien,I am also working on an eye mouse and a "newbie/student".Was wondering if you could provide me with a guideline on how to approach the mouse control(move and click the mouse) based on the eye pupil movement.How do I link the co ordinates of the windows mouse to the eye movement.I have achieved the tracking of the eyes using OpenCV and VS C++. Im sure by now you have successfully completed the eyemouse project.Any guidance is much appreciated. Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900