Hi
My project is building a dictionary and I have done everything for it. Just I want to add a feature to my dictionary which is able the user to leave the cursor on the word which he/she want to find the meaning. after that the meaning appear in a box. My problem is I don't know how to write the code to detect the Mouse Idle time for two seconds and perform a double-click to highlight the text. the rest I can do. I just want to know how can I recognize the mouse IDLE time and assign a double click to it. Can you guide me in this case?

Sincerely

My problem is I don't know how to write the code to detect the Mouse Idle time for two seconds and perform a double-click to highlight the text. the rest I can do. I just want to know how can I recognize the mouse IDLE time and assign a double click to it.

You can use the MouseHover event to detect the mouse being idle over a control.

If your control is some sort of text box, the GetCharIndexFromPosition method can tell you where in the text the mouse is when the MouseHover event happens.

I don't know of any automatic way to find the extents of the entire word given a single text index, but it shouldn't be too hard to scan in both directions from the character index to find non-word characters.

Then you can use the Select method (again, assuming some sort of text box) to actually select the word once you have the character indices of the start and end of the word.

You can use the MouseHover event to detect the mouse being idle over a control.

If your control is some sort of text box, the GetCharIndexFromPosition method can tell you where in the text the mouse is when the MouseHover event happens.

I don't know of any automatic way to find the extents of the entire word given a single text index, but it shouldn't be too hard to scan in both directions from the character index to find non-word characters.

Then you can use the Select method (again, assuming some sort of text box) to actually select the word once you have the character indices of the start and end of the word.

thanks for your comment. But MouseHover and all of the other events by the mounth are Not GLOBAL. I am looking for a method which I can know when the mouse is IDLE for 3 second and after that perform double-click event. for the double-click I found the method which I need. But still I'm having problem with how can I know when the mouse is Idle ( for example 3 seconds) in any application (Global).

you can always override the WndProc() function to gain more control over the windows messages..for this purpose you can follow the steps below
- look for WM_NCHITTEST message in the override section of the WndProc
- start a timer that has the interval of 3000
- n in the timer's tick() event..do whatever task you wanted to perform

Basically you can override the WndProc as given below

protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_NCHITTEST)
            {
                ///perform some task here,e.g. start the timer                
            }
            base.WndProc(ref m);
        }

plus you have to define WM_NCHITTEST prior to its use

private const int WM_NCHITTEST=0x0084;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.