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. findwindowex and gettext ???

findwindowex and gettext ???

Scheduled Pinned Locked Moved Windows Forms
question
14 Posts 3 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 Offline
    T Offline
    TALHAKOSEN
    wrote on last edited by
    #1

    chieldHwnd= FindWindowEx(parentHwnd, chieldHwnd, "obj_EDIT", null); int length = SendMessage(chieldHwnd, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0); if (length > 0) { StringBuilder sb = new StringBuilder(length); int numChars = SendMessage(chieldHwnd, WM_GETTEXT, (IntPtr)(length + 1), sb); listBox1.Items.Add("in Textbox : " + sb); } this code takes a text in textbox but form has 2 textboxes and it takes last textbox's text how can i get the specified text. username ------------- password ------------- both of them empty and it takes allways password's text of textbox

    thanks for everything i have...

    G D 2 Replies Last reply
    0
    • T TALHAKOSEN

      chieldHwnd= FindWindowEx(parentHwnd, chieldHwnd, "obj_EDIT", null); int length = SendMessage(chieldHwnd, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0); if (length > 0) { StringBuilder sb = new StringBuilder(length); int numChars = SendMessage(chieldHwnd, WM_GETTEXT, (IntPtr)(length + 1), sb); listBox1.Items.Add("in Textbox : " + sb); } this code takes a text in textbox but form has 2 textboxes and it takes last textbox's text how can i get the specified text. username ------------- password ------------- both of them empty and it takes allways password's text of textbox

      thanks for everything i have...

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

      You need to call FindWindowEx in a loop passing previous values as hwndChildAfter. The loop should end when FindWindowEx returns NULL. By the way, winapi questions should be asked here: Visual C++ / MFC[^]

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

      T 2 Replies Last reply
      0
      • G Giorgi Dalakishvili

        You need to call FindWindowEx in a loop passing previous values as hwndChildAfter. The loop should end when FindWindowEx returns NULL. By the way, winapi questions should be asked here: Visual C++ / MFC[^]

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

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

        thx and i am sorry that i send wrong place (

        thanks for everything i have...

        1 Reply Last reply
        0
        • G Giorgi Dalakishvili

          You need to call FindWindowEx in a loop passing previous values as hwndChildAfter. The loop should end when FindWindowEx returns NULL. By the way, winapi questions should be asked here: Visual C++ / MFC[^]

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

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

          private int GetChildHandle(int parent, string className) { int child = FindWindowEx(parent, IntPtr.Zero, className, null); return child; } public void DoExternalWrite(string text) { int parent = FindWindow("obj_Form", "Adobe Creative Suite 2 by cvs/SSG"); int child = GetChildHandle(parent, "obj_BUTTON");// is a group box //in this groupbox there are two text box int child2 = GetChildHandle(child, "obj_EDIT"); SendMessage(child, WM_SETTEXT, IntPtr.Zero, text); } 1 --------- 2 --------- it types mytext to this textbox why ??

          thanks for everything i have...

          G 1 Reply Last reply
          0
          • T TALHAKOSEN

            private int GetChildHandle(int parent, string className) { int child = FindWindowEx(parent, IntPtr.Zero, className, null); return child; } public void DoExternalWrite(string text) { int parent = FindWindow("obj_Form", "Adobe Creative Suite 2 by cvs/SSG"); int child = GetChildHandle(parent, "obj_BUTTON");// is a group box //in this groupbox there are two text box int child2 = GetChildHandle(child, "obj_EDIT"); SendMessage(child, WM_SETTEXT, IntPtr.Zero, text); } 1 --------- 2 --------- it types mytext to this textbox why ??

            thanks for everything i have...

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

            So where is the loop?

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

            T 1 Reply Last reply
            0
            • G Giorgi Dalakishvili

              So where is the loop?

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

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

              private int GetChildHandle(int parent, string className) { int childafter=0; while (childafter != null ) { childafter = FindWindowEx(parent, childafter, className, null); } return childafter; } ????????????

              thanks for everything i have...

              G 1 Reply Last reply
              0
              • T TALHAKOSEN

                private int GetChildHandle(int parent, string className) { int childafter=0; while (childafter != null ) { childafter = FindWindowEx(parent, childafter, className, null); } return childafter; } ????????????

                thanks for everything i have...

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

                And?

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

                T 1 Reply Last reply
                0
                • G Giorgi Dalakishvili

                  And?

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

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

                  private int GetChildHandle(int parent, string className) { int childafter = FindWindowEx(parent, 0, className, null); while (childafter != 0 ) { childafter = FindWindowEx(parent, childafter, className, null); listBox1.Items.Add(childafter); } return childafter; } parent takes the hwnd with findwindow() classname i gave when i use that functions, it gives the same . It add to listbox only second textbox hwnd, i am going to crayz ???

                  thanks for everything i have...

                  G 1 Reply Last reply
                  0
                  • T TALHAKOSEN

                    private int GetChildHandle(int parent, string className) { int childafter = FindWindowEx(parent, 0, className, null); while (childafter != 0 ) { childafter = FindWindowEx(parent, childafter, className, null); listBox1.Items.Add(childafter); } return childafter; } parent takes the hwnd with findwindow() classname i gave when i use that functions, it gives the same . It add to listbox only second textbox hwnd, i am going to crayz ???

                    thanks for everything i have...

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

                    Why are you adding hwnds to the listbox? I thought you wanted to get text from them.

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

                    T 1 Reply Last reply
                    0
                    • G Giorgi Dalakishvili

                      Why are you adding hwnds to the listbox? I thought you wanted to get text from them.

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

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

                      yes you are right just i wanna see which hwnd i can take just because of this. and always it takes last one hwnd so always takes last one's text

                      thanks for everything i have...

                      G 1 Reply Last reply
                      0
                      • T TALHAKOSEN

                        yes you are right just i wanna see which hwnd i can take just because of this. and always it takes last one hwnd so always takes last one's text

                        thanks for everything i have...

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

                        You are returning only the last one. Find text for all the hwnds you get by the loop.

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

                        T 1 Reply Last reply
                        0
                        • G Giorgi Dalakishvili

                          You are returning only the last one. Find text for all the hwnds you get by the loop.

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

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

                          could you help on this? how can i do that?

                          thanks for everything i have...

                          G 1 Reply Last reply
                          0
                          • T TALHAKOSEN

                            chieldHwnd= FindWindowEx(parentHwnd, chieldHwnd, "obj_EDIT", null); int length = SendMessage(chieldHwnd, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0); if (length > 0) { StringBuilder sb = new StringBuilder(length); int numChars = SendMessage(chieldHwnd, WM_GETTEXT, (IntPtr)(length + 1), sb); listBox1.Items.Add("in Textbox : " + sb); } this code takes a text in textbox but form has 2 textboxes and it takes last textbox's text how can i get the specified text. username ------------- password ------------- both of them empty and it takes allways password's text of textbox

                            thanks for everything i have...

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #13

                            Just throwing my 2 cents in... There is one little problem with using WM_GETTEXT to get the string out of textboxes - reliability. There is nothing that says that the control has to respond to that message. There are subclassed textbox classes being used that ignore the WM_GETTEXT message, and hence, return nothing. A password textbox sounds like a good candidate for a customized version of a textbox control that ignores the message, doesn't it?

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                 2006, 2007, 2008

                            1 Reply Last reply
                            0
                            • T TALHAKOSEN

                              could you help on this? how can i do that?

                              thanks for everything i have...

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

                              Well, you get text by sending messages to the control identified by the hwnd, don't you? So send those messages to all the childhwnds you get.

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

                              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