Question

I am developing an application that maps users eye movements with the cursor movements, hence developing ahands free cursor control system.

I am using Open CV library's .NET Wrapper for C# i.e. Emgu CV for development.

I am stuck at a point where I want to open a file/folder such that when a cursor is placed over a file/folder for say 3 to 5 seconds, the file/folder should open up or just perform a double-click event of a conventional mouse.

What could I use so as to solve this problem?

Was it helpful?

Solution

    Timer timer = new System.Timers.Timer(5000);//5 seconds
    timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);

    private void form_MouseHover(object sender, System.EventArgs e) 
    {            
        timer.Start();
    }

    private void form_MouseLeave(object sender, System.EventArgs e) 
    {            
        timer.Stop();
    }

    void timer_Elapsed(object sender, ElapsedEventArgs e)
    {
        timer.Stop();
        OpenFileOrFolder();//Edit : implement your file / folder opening logic here
    }

OTHER TIPS

I guess you need to break it down:

  1. Detect when the mouse moves or hovers
  2. Send a double click

For 1, I'd be looking at: capturing WM_MOUSEMOVE if you want your own definition of 'hovering'. For example, having a greater threshold for how much movement you'll tolerate and still consider it a 'hover'. Or, you could use the OS defined threshold and look for WM_MOUSEHOVER

For 2, SendInput should get you there

I'm assuming here, you don't actually care what's under the mouse per-se. As in, you're not going to do different behavior depending on what's under the mouse. For example, you'd send the double click when hovering over the titlebar, as well as if you were hovering over the file.

This article on project builds up a Spy++ style app, which should help.

Are you mapping eye control to the mouse pointer? The MouseHover event may be useful:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousehover.aspx

As well as MouseEnter, MouseLeave, etc.

If you're controlling a separate element (i.e., not the mouse) with the eyes, then I had to do something similar in WPF. It ultimately came down to mapping control coordinates to mouse location, counting the time within the bounds of that control, then calling the mouse click event handler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top