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. Windows Forms
  4. how to get text with api ???

how to get text with api ???

Scheduled Pinned Locked Moved Windows Forms
questionjsontutorial
19 Posts 4 Posters 0 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.
  • T TALHAKOSEN

    thx for your help, but i cant do it :( Do you have basic example code can retrieve text pls ??

    thanks for everything i have...

    G Offline
    G Offline
    Giorgi Dalakishvili
    wrote on last edited by
    #4

    You need HWND of the control you want to retrieve text from. Then you need to send WM_GetText message using SendMessage function. I think you have enough keywords now to search on google.

    Giorgi Dalakishvili #region signature My Articles / My Latest Article[^] / My blog[^] #endregion

    T 1 Reply Last reply
    0
    • G Giorgi Dalakishvili

      WM_GETTEXT Message[^]

      Giorgi Dalakishvili #region signature my articles My blog[^] #endregion

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #5

      WM_GETTEXT? Really? How did you deduce that this person is working in native code and not .NET?

      led mike

      G 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        You need HWND of the control you want to retrieve text from. Then you need to send WM_GetText message using SendMessage function. I think you have enough keywords now to search on google.

        Giorgi Dalakishvili #region signature My Articles / My Latest Article[^] / My blog[^] #endregion

        T Offline
        T Offline
        TALHAKOSEN
        wrote on last edited by
        #6

        I am trying to find smt but i think i dont know exactly how to use that i wrote smt like that public const int WM_GETTEXT = 0X00D; [DllImport("USER32.DLL", CharSet = CharSet.Auto)] public static extern int SendMessage(int hWnd, uint msg, int wparam, StringBuilder text); [DllImport("User32.dll")] public static extern int FindWindow(String lpClassName, String lpWindowName); [DllImport("user32.dll")] private static extern int FindWindowEx(int parentHandle, int childAfter, string className, string windowTitle); hwnd = FindWindow(null, "Adobe Creative Suite 2 by cvs/SSG"); StringBuilder titletext = new StringBuilder(256); StringBuilder artisttext = new StringBuilder(256); StringBuilder timetext = new StringBuilder(256); StringBuilder totaltimetext = new StringBuilder(256); hwnd2 = FindWindowEx(hwnd, 0, "obj_BUTTON", "Activation"); hwnd3 = FindWindowEx(hwnd2, 0, "obj_EDIT", null); MessageBox.Show( SendMessage(hwnd3, WM_GETTEXT, 256, 256).ToString()); i can handle the hwnd that i need in parent then child form. hwnd3 is the textbox's hwnd after that time how can i read what is written in that

        thanks for everything i have...

        T 1 Reply Last reply
        0
        • L led mike

          WM_GETTEXT? Really? How did you deduce that this person is working in native code and not .NET?

          led mike

          G Offline
          G Offline
          Giorgi Dalakishvili
          wrote on last edited by
          #7

          led mike wrote:

          How did you deduce that this person is working in native code and not .NET?

          Intuition. As you can see from his/her last reply I was correct.

          Giorgi Dalakishvili #region signature My Articles / My Latest Article[^] / My blog[^] #endregion

          L 1 Reply Last reply
          0
          • G Giorgi Dalakishvili

            led mike wrote:

            How did you deduce that this person is working in native code and not .NET?

            Intuition. As you can see from his/her last reply I was correct.

            Giorgi Dalakishvili #region signature My Articles / My Latest Article[^] / My blog[^] #endregion

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #8

            Giorgi Dalakishvili wrote:

            Intuition.

            Wow. Nice work! :)

            led mike

            T 1 Reply Last reply
            0
            • L led mike

              Giorgi Dalakishvili wrote:

              Intuition.

              Wow. Nice work! :)

              led mike

              T Offline
              T Offline
              TALHAKOSEN
              wrote on last edited by
              #9

              in fact i am newby so i couldnt understand by seeing WM_GETTEXT on his answer. i just needed more help. Thanks...

              thanks for everything i have...

              1 Reply Last reply
              0
              • T TALHAKOSEN

                I am trying to find smt but i think i dont know exactly how to use that i wrote smt like that public const int WM_GETTEXT = 0X00D; [DllImport("USER32.DLL", CharSet = CharSet.Auto)] public static extern int SendMessage(int hWnd, uint msg, int wparam, StringBuilder text); [DllImport("User32.dll")] public static extern int FindWindow(String lpClassName, String lpWindowName); [DllImport("user32.dll")] private static extern int FindWindowEx(int parentHandle, int childAfter, string className, string windowTitle); hwnd = FindWindow(null, "Adobe Creative Suite 2 by cvs/SSG"); StringBuilder titletext = new StringBuilder(256); StringBuilder artisttext = new StringBuilder(256); StringBuilder timetext = new StringBuilder(256); StringBuilder totaltimetext = new StringBuilder(256); hwnd2 = FindWindowEx(hwnd, 0, "obj_BUTTON", "Activation"); hwnd3 = FindWindowEx(hwnd2, 0, "obj_EDIT", null); MessageBox.Show( SendMessage(hwnd3, WM_GETTEXT, 256, 256).ToString()); i can handle the hwnd that i need in parent then child form. hwnd3 is the textbox's hwnd after that time how can i read what is written in that

                thanks for everything i have...

                T Offline
                T Offline
                TALHAKOSEN
                wrote on last edited by
                #10

                By the way i found a url that show a code retrieve text http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d52b9825-dd13-4fd4-bfa8-722114f2ba44/ :)

                thanks for everything i have...

                1 Reply Last reply
                0
                • T TALHAKOSEN

                  Hi all, i found some code retrieve form's caption but i need to get text from a textbox or label on a windows form which i want. how can i do this ? i am really new on api. thanks...:confused::confused:

                  thanks for everything i have...

                  W Offline
                  W Offline
                  WinSolution
                  wrote on last edited by
                  #11

                  Can i have an example of getting text from another application form running as separate process If so please help me and I'll be very thankful to you if you provide me a C# 2003/2005 project I will be waiting for your reply

                  T 1 Reply Last reply
                  0
                  • W WinSolution

                    Can i have an example of getting text from another application form running as separate process If so please help me and I'll be very thankful to you if you provide me a C# 2003/2005 project I will be waiting for your reply

                    T Offline
                    T Offline
                    TALHAKOSEN
                    wrote on last edited by
                    #12

                    it takes the button names on calculator using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace apiGetText { public partial class Form1 : Form { private const int WM_GETTEXT = 0x000D; private const int WM_SETTEXT = 0x000C; private const int WM_GETTEXTLENGTH = 0x000E; [DllImport("User32.dll")] public static extern uint GetMenuItemID(int hMenu, int nPos); [DllImport("User32.dll")] public static extern int FindWindow( String lpClassName, String lpWindowName); [DllImport("user32.dll")] private static extern int FindWindowEx( int parentHandle, int childAfter, string className, string windowTitle); [DllImport("User32.dll")] public static extern Int32 SendMessage( int hWnd, // handle to destination window int Msg, // message IntPtr wParam, // first message parameter StringBuilder lParam); [DllImport("User32.dll")] public static extern Int32 SendMessage( int hWnd, // handle to destination window int Msg, // message IntPtr wParam, // first message parameter IntPtr lParam); // second message parameter private void button1_Click(object sender, EventArgs e) { int calculatorHwnd; int btnHwndGrp; // youcan find SciCalc on spy++ --- > findwindow ----> classname calculatorHwnd = FindWindow("SciCalc", "Calculator"); btnHwndGrp = FindWindowEx(calculatorHwnd, 0, "BUTTON", null); int length = SendMessage(btnHwndGrp, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0); if (length > 0) { StringBuilder sb = new StringBuilder(length); SendMessage(btnHwndGrp, WM_GETTEXT, (IntPtr)(length + 1), sb); //this shows the text MessageBox.Show(sb.ToString()); } } } }

                    thanks for everything i have...

                    W 2 Replies Last reply
                    0
                    • T TALHAKOSEN

                      it takes the button names on calculator using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace apiGetText { public partial class Form1 : Form { private const int WM_GETTEXT = 0x000D; private const int WM_SETTEXT = 0x000C; private const int WM_GETTEXTLENGTH = 0x000E; [DllImport("User32.dll")] public static extern uint GetMenuItemID(int hMenu, int nPos); [DllImport("User32.dll")] public static extern int FindWindow( String lpClassName, String lpWindowName); [DllImport("user32.dll")] private static extern int FindWindowEx( int parentHandle, int childAfter, string className, string windowTitle); [DllImport("User32.dll")] public static extern Int32 SendMessage( int hWnd, // handle to destination window int Msg, // message IntPtr wParam, // first message parameter StringBuilder lParam); [DllImport("User32.dll")] public static extern Int32 SendMessage( int hWnd, // handle to destination window int Msg, // message IntPtr wParam, // first message parameter IntPtr lParam); // second message parameter private void button1_Click(object sender, EventArgs e) { int calculatorHwnd; int btnHwndGrp; // youcan find SciCalc on spy++ --- > findwindow ----> classname calculatorHwnd = FindWindow("SciCalc", "Calculator"); btnHwndGrp = FindWindowEx(calculatorHwnd, 0, "BUTTON", null); int length = SendMessage(btnHwndGrp, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0); if (length > 0) { StringBuilder sb = new StringBuilder(length); SendMessage(btnHwndGrp, WM_GETTEXT, (IntPtr)(length + 1), sb); //this shows the text MessageBox.Show(sb.ToString()); } } } }

                      thanks for everything i have...

                      W Offline
                      W Offline
                      WinSolution
                      wrote on last edited by
                      #13

                      I am now at office : I will try at home : Thanks A Lot For Helping

                      T 1 Reply Last reply
                      0
                      • W WinSolution

                        I am now at office : I will try at home : Thanks A Lot For Helping

                        T Offline
                        T Offline
                        TALHAKOSEN
                        wrote on last edited by
                        #14

                        Good luck !)

                        thanks for everything i have...

                        1 Reply Last reply
                        0
                        • T TALHAKOSEN

                          it takes the button names on calculator using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace apiGetText { public partial class Form1 : Form { private const int WM_GETTEXT = 0x000D; private const int WM_SETTEXT = 0x000C; private const int WM_GETTEXTLENGTH = 0x000E; [DllImport("User32.dll")] public static extern uint GetMenuItemID(int hMenu, int nPos); [DllImport("User32.dll")] public static extern int FindWindow( String lpClassName, String lpWindowName); [DllImport("user32.dll")] private static extern int FindWindowEx( int parentHandle, int childAfter, string className, string windowTitle); [DllImport("User32.dll")] public static extern Int32 SendMessage( int hWnd, // handle to destination window int Msg, // message IntPtr wParam, // first message parameter StringBuilder lParam); [DllImport("User32.dll")] public static extern Int32 SendMessage( int hWnd, // handle to destination window int Msg, // message IntPtr wParam, // first message parameter IntPtr lParam); // second message parameter private void button1_Click(object sender, EventArgs e) { int calculatorHwnd; int btnHwndGrp; // youcan find SciCalc on spy++ --- > findwindow ----> classname calculatorHwnd = FindWindow("SciCalc", "Calculator"); btnHwndGrp = FindWindowEx(calculatorHwnd, 0, "BUTTON", null); int length = SendMessage(btnHwndGrp, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0); if (length > 0) { StringBuilder sb = new StringBuilder(length); SendMessage(btnHwndGrp, WM_GETTEXT, (IntPtr)(length + 1), sb); //this shows the text MessageBox.Show(sb.ToString()); } } } }

                          thanks for everything i have...

                          W Offline
                          W Offline
                          WinSolution
                          wrote on last edited by
                          #15

                          Thanks I have achieve the goal by using the example you have provided but i need help your in following problem explained in image link untitled.JPG

                          T 1 Reply Last reply
                          0
                          • W WinSolution

                            Thanks I have achieve the goal by using the example you have provided but i need help your in following problem explained in image link untitled.JPG

                            T Offline
                            T Offline
                            TALHAKOSEN
                            wrote on last edited by
                            #16

                            there are an error on the path

                            thanks for everything i have...

                            W 1 Reply Last reply
                            0
                            • T TALHAKOSEN

                              there are an error on the path

                              thanks for everything i have...

                              W Offline
                              W Offline
                              WinSolution
                              wrote on last edited by
                              #17

                              Click on the link in previous reply a new window will open the press enter after the url or press GO button . it will work i will be waiting for you help thanks

                              T 1 Reply Last reply
                              0
                              • W WinSolution

                                Click on the link in previous reply a new window will open the press enter after the url or press GO button . it will work i will be waiting for you help thanks

                                T Offline
                                T Offline
                                TALHAKOSEN
                                wrote on last edited by
                                #18

                                anyway you can send the picture to my email it says this, HTTP1.1 STATUS 403 Remote Access to this object forbidden This file cannot be directly accessed from a remote site, but must be linked through the Brinkster Member's site.

                                thanks for everything i have...

                                W 1 Reply Last reply
                                0
                                • T TALHAKOSEN

                                  anyway you can send the picture to my email it says this, HTTP1.1 STATUS 403 Remote Access to this object forbidden This file cannot be directly accessed from a remote site, but must be linked through the Brinkster Member's site.

                                  thanks for everything i have...

                                  W Offline
                                  W Offline
                                  WinSolution
                                  wrote on last edited by
                                  #19

                                  how i can get your email address i am not able to view email address in your profile

                                  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