none
get the text under mouse pointer?

    Question

  • howto get  the text under the mouse pointer from the other application into the .net winform.

     

    Friday, June 23, 2006 2:17 AM

Answers

  • "from the other application" is the killer requirement here.  You'll need to P/Invoke some Windows API functions:
    - Capture the mouse so you can click on a window outside the form
    - WindowFromPoint to find the window handle
    - SendMessage WM_GETTEXT to retrieve the text

    Copy and Paste through the clipboard sounds a lot easier...

    Friday, June 23, 2006 7:52 PM
    Moderator

All replies

  • Set up a handler function for the MouseHover event of all the controls you are interested in looking at.  All the things you are looking at should have a Text property (otherwise it doesn't have text... and you aren't interested).

    Public Sub LookAtText (sender as object, e as SomeEventArgs) Handles Button1.MouseHover, TextBox1.MouseHover, ... and so on

    Within that function, the Text property of the sender object should have the info you are looking for (since the sender will be the control the mouse is hovering over).

     

    Friday, June 23, 2006 7:25 PM
  • "from the other application" is the killer requirement here.  You'll need to P/Invoke some Windows API functions:
    - Capture the mouse so you can click on a window outside the form
    - WindowFromPoint to find the window handle
    - SendMessage WM_GETTEXT to retrieve the text

    Copy and Paste through the clipboard sounds a lot easier...

    Friday, June 23, 2006 7:52 PM
    Moderator