Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My code only get from textbox I want to get on window such as a weppage or text file HOW ?

C#
private void txtHoverWord_MouseMove(object sender, MouseEventArgs e)
{
    if (!(sender is TextBox)) return;
    var targetTextBox = sender as TextBox;
    if (targetTextBox.TextLength < 1) return;

    var currentTextIndex = targetTextBox.GetCharIndexFromPosition(e.Location);
    var wordRegex = new Regex(@"(\w+)");
    var words = wordRegex.Matches(targetTextBox.Text);
    if (words.Count < 1) return;

    var currentWord = string.Empty;
    for (var i = words.Count - 1; i >= 0; i--)
    {
        if (words[i].Index <= currentTextIndex)
        {
            currentWord = words[i].Value;
            break;
        }
    }

    if (currentWord == string.Empty) return;
    tooltip1.SetToolTip(targetTextBox, currentWord);
}
Posted

1 solution

What you are asking for is close to impossible without sincere effort.
Remember that since your program will have absolutely no connection with the target application which has rendered the word in the first place (your browser, notepad etc), you have to resort to different tactics than just a simple mouse hover event.
My suggestion is to try to capture the area under the mouse and then applying OCR.
I can't think of any other way this can be done.
 
Share this answer
 

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