C#, getting the full text of a window (ala AHK)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RodneyAnonymous
    New Member
    • Oct 2007
    • 15

    C#, getting the full text of a window (ala AHK)

    Hello everyone!

    I've got an application with multiple MDI windows that I need to be able to get the full text of (so the information can be parsed through my tool). What I need is a C# equivalent of the AHK function WinGetText, or a suggestion for a better way of going about it.

    Much <3 for halp. Thanks!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    What do you mean "full text"? You mean the window title?
    use:
    Code:
    myform.Text

    Comment

    • RodneyAnonymous
      New Member
      • Oct 2007
      • 15

      #3
      Not trying to be rude, but it doesn't seem like you really read my question before you responded. I'm not trying to get the Title of my form. I'm trying to interface with a separate application, which contains multiple MDI windows, and get all the text currently being displayed by it, in the same way that the WinGetText function from AutoHotkey does.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Well, not trying to be rude, but your question was rather poorly written.

        I don't believe there are any .NET objects that will do this, you will probably have to use DLLImport and use the unmanaged function you mentioned.
        The Process object can get you some information, but not all of it I don't believe.

        Comment

        • RodneyAnonymous
          New Member
          • Oct 2007
          • 15

          #5
          Originally posted by Plater
          Well, not trying to be rude, but your question was rather poorly written.

          I don't believe there are any .NET objects that will do this, you will probably have to use DLLImport and use the unmanaged function you mentioned.
          The Process object can get you some information, but not all of it I don't believe.
          Question seemed pretty clear to me.

          I'm fully expecting to have to use API functions to do this. What very little I've been able to find points to using SendMessage and WM_GETTEXT to get information from specific controls, once I have their handles. Problem is, looping through every control in the outside app seems stupidly inefficient when all I need is to get text information from a few Edit fields within the active MDI child window. And if I just went through all the Edits, I don't really have a way of telling which returned text corresponded to which Edit field.

          Comment

          • RodneyAnonymous
            New Member
            • Oct 2007
            • 15

            #6
            I was able to put together something of a solution for my issue, but this has created a new problem. Since the locations of the Edit boxes that I need are always static in relation to their MDI window, I was able to use WindowFromPoint to get an initial Edit's handle, and then change X and Y coordinates to get others. Using SendMessage with WM_GETTEXT worked to get the text out of some controls.

            This has, however, created a new problem. There are different levels of access to the program I am interfacing with, and some users may have certain text fields and combo boxes disabled for them. WindowFromPoint will not return the handle for any disabled controls.

            Is there a way to get around this?

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              This is really out of the scope of .NET now, you might try asking someone to bump this over to the "C/C++" forum for better help on the API calls.

              Comment

              Working...