Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Other program access and data extraction

Other program access and data extraction

Scheduled Pinned Locked Moved C / C++ / MFC
csharpjavacomquestion
7 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cocaya
    wrote on last edited by
    #1

    Hello. I'm trying to get text data from another program. The window handle was found. Please check the image link. CLICK Here - Attach Image Link But I'm not sure what to do next. Should I use something similar to the GetDlgCtrlID method? I do not know. The return is -1. Please advise. thank you.

    V L 2 Replies Last reply
    0
    • C cocaya

      Hello. I'm trying to get text data from another program. The window handle was found. Please check the image link. CLICK Here - Attach Image Link But I'm not sure what to do next. Should I use something similar to the GetDlgCtrlID method? I do not know. The return is -1. Please advise. thank you.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      There are similar questions/discussions in different forums. Have a look at [python - Need a way to access control in a window with control id using pywinauto - Stack Overflow](https://stackoverflow.com/questions/40252343/need-a-way-to-access-control-in-a-window-with-control-id-using-pywinauto)

      1 Reply Last reply
      0
      • C cocaya

        Hello. I'm trying to get text data from another program. The window handle was found. Please check the image link. CLICK Here - Attach Image Link But I'm not sure what to do next. Should I use something similar to the GetDlgCtrlID method? I do not know. The return is -1. Please advise. thank you.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        cocaya wrote:

        the GetDlgCtrlID method

        That will only return a valid id if the handle is that of an actual dialog control. But even if it does, the id will not be of any use. To get the text of a Window in another process, you must send the WM_GETTEXT message (Winuser.h) - Win32 apps | Microsoft Docs[^] to it. But you first need to know that the Window contains valid text.

        C 1 Reply Last reply
        0
        • L Lost User

          cocaya wrote:

          the GetDlgCtrlID method

          That will only return a valid id if the handle is that of an actual dialog control. But even if it does, the id will not be of any use. To get the text of a Window in another process, you must send the WM_GETTEXT message (Winuser.h) - Win32 apps | Microsoft Docs[^] to it. But you first need to know that the Window contains valid text.

          C Offline
          C Offline
          cocaya
          wrote on last edited by
          #4

          *CLICK here : Attach Image Link handle => 0x001229e8 GetControlText(IntPtr hWnd){ // Get the size of the string required to hold the window title (including trailing null.) Int32 titleSize = SendMessage((int)hWnd, WM_GETTEXTLENGTH, 0, 0).ToInt32(); // If titleSize is 0, there is no title so return an empty string (or null) if (titleSize == 0) return String.Empty; StringBuilder title = new StringBuilder(titleSize + 1); SendMessage(hWnd, (int)WM_GETTEXT, title.Capacity, title); return title.ToString(); } Thanks reply, but When this function is executed, String.Empty is returned. How can I get grid table values?? I desperately want to solve it. please help me..

          L 1 Reply Last reply
          0
          • C cocaya

            *CLICK here : Attach Image Link handle => 0x001229e8 GetControlText(IntPtr hWnd){ // Get the size of the string required to hold the window title (including trailing null.) Int32 titleSize = SendMessage((int)hWnd, WM_GETTEXTLENGTH, 0, 0).ToInt32(); // If titleSize is 0, there is no title so return an empty string (or null) if (titleSize == 0) return String.Empty; StringBuilder title = new StringBuilder(titleSize + 1); SendMessage(hWnd, (int)WM_GETTEXT, title.Capacity, title); return title.ToString(); } Thanks reply, but When this function is executed, String.Empty is returned. How can I get grid table values?? I desperately want to solve it. please help me..

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            It depends on how that grid controls its content. A simple WM_GETTEXT message is unlikely to return anything. If it is a Windows ListView then you could try some of the LVM_GETxxx messages: List View Messages - Win32 apps | Microsoft Docs[^].

            C 1 Reply Last reply
            0
            • L Lost User

              It depends on how that grid controls its content. A simple WM_GETTEXT message is unlikely to return anything. If it is a Windows ListView then you could try some of the LVM_GETxxx messages: List View Messages - Win32 apps | Microsoft Docs[^].

              C Offline
              C Offline
              cocaya
              wrote on last edited by
              #6

              Thanks for the advice. I tried the following, but the return value is 0. int nTextLength = SendMessage(hwnd6, WM_GETTEXTLENGTH, 0, 0).ToInt32(); How should I approach it?ㅜ.ㅜ CLICK Here : MS inspect.exe capture.

              L 1 Reply Last reply
              0
              • C cocaya

                Thanks for the advice. I tried the following, but the return value is 0. int nTextLength = SendMessage(hwnd6, WM_GETTEXTLENGTH, 0, 0).ToInt32(); How should I approach it?ㅜ.ㅜ CLICK Here : MS inspect.exe capture.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                1. Why are you calling ToInt32 on a value that is already an int type? 2. If WM_GETTEXTLENGTH returns zero, then that tells you the Window is not a Text type. As I said yesterday, if the contents are shown in a grid then you need to find out what actual control it is, and use the control's methods to extract the contents.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups