Hello,

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:

        [DllImport("user32.dll")]
        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++)
                     {
                         try
                         {
                             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 { }
                     }
                 }
             }
         }

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.