I have an application that is not mine, that has 6 textboxes with values on it.
I am trying to use the windows API to retreive the values from those textBoxes. I know that they exists in a control named "Panel1".
So I have come so far in the code like below to find the "Panel1". But from here, I can't manage to find the textboxes and get their values?
I have used "SysExp" software which do find those values for those textboxes so it is possible in somehow.

Code attempt:

        static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, [MarshalAs(UnmanagedType.LPStr)] StringBuilder lParam);

         private void button1_Click(object sender, EventArgs e)

             foreach (Process p in Process.GetProcesses())
                 if (p.MainWindowTitle.ToString().ToLower().Contains("applicationname"))

                     IntPtr applicationnamewindow = p.MainWindowHandle;
                     List<IntPtr> GetAllChildrenHandles = GetAllChildrenWindowHandles(applicationnamewindow, 100);
                     for (int i = 0; i < GetAllChildrenHandles.Count; i++)
                             IntPtr childHandle = (IntPtr)GetAllChildrenHandles[i];

                             const int WM_GETTEXT = 0x0D;
                             StringBuilder sb = new StringBuilder();
                             IntPtr retVal = SendMessage(childHandle, WM_GETTEXT, 10, sb);

                             if (sb.ToString().ToLower() == "panel1")

                                 //Inside this panel1 window. There exists 6 textBoxes. How to find them and get the value from them???
                         catch { }
2 Years
Discussion Span
Last Post by Suzie999

I've not done this in c# but I'm sure the windows api will be quite ckunky for it and might not even work on non standard win32 windows and controls,

So I point you toward ui automation

Edited by Suzie999

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.