Can I get word under mouse in any program in C# app?
|
in a texbox for examle, handle the MouseHover Event, and then you might have to find a way to get the x y co-ordinates, and the then the word location and copy it to clipboard or select it |
|
You can use TextBox.GetCharIndexFromPosition to get the index the mouse is over, then search backwards and forwards from that index for word boundaries and you'll have your word. |
|
I’ve not tried it in C# yet, but I have an
article in Delphi that shows you how to hook your code to global mouse events.
It is not Delphi specific in the sense that you use Windows API calls to do the hook. On the fact about how to get the text from the textbox (you get the window handle through the hook call-back) displaying the text you want is a thing I would very much like to know myself. But, should you be able to find the “class” of the “textbox” window does not mean that the text displayed on the screen is made public via some method or property (it could be a custom “textbox” drawn by the application it self displaying text from a private property/method).
|