-1

I need to find textBox's user name and password and button in windows form popup.

I found the PopUp id ,but me textBox's inside of element/child that have the same classes and i cant find the specific text box that i need , look at image you will understand.

I have there 8 child with same class and each one have same elemets that i need,itried to find them by child after parament but faild.

     int LoginPop = FindWindow(sLoginPopUpClassName, sLoginPopUpName);//found
      int LoginPopForm = FindWindowEx(LoginPop, 0, sLoginPopUpClassName, sLoginPopUpName);//found
  int LoginPopUserNameArea = FindWindowEx(LoginPopForm, 0, ClassName, sLoginPopUpAreaName);    

    > LoginPopForm have 8 child with my txtbox's

    //here i tried to find my txtBox's and button with child after ,but fail.
   int LoginPopUserNameArea = FindWindowEx(LoginPopForm, 7, sClassName, saName);//CtrlNotifySink 
   int LoginPopPasswordArea = FindWindowEx(LoginPopForm, 8, sClassName, sName);
   int LoginPopButtonArea = FindWindowEx(LoginPopForm, 3, sClassName, sName);


   int LoginPopTextBoxUserName = FindWindowEx(LoginPopUserNameArea, 0, sClassName, sName);
   int LoginPopTextBoxPassword = FindWindowEx(LoginPopPasswordArea, 0, sClassName, sName);
   int LoginPopButtonOk = FindWindowEx(LoginPopButtonArea, 0, ClassName, Name);

See this image:

enter image description here

Vladimir Potapov
  • 2,347
  • 7
  • 44
  • 71
  • No, i am trying to insert the UserName and Password and press Login button.But to this this i need to find id of txtBox. – Vladimir Potapov Dec 09 '14 at 10:58
  • OK, my apology if I'm wrong. I'm rather paranoid about this kind of thing, bad things have happened to someone I know. – RenniePet Dec 09 '14 at 10:59

1 Answers1

0

I built a function which goes over all children and finds what I need.

I gebuged FindSpecificWindow and use (SendMessage) to set text and like this I found the place of my element by changed text.

Here it is:

ChildPlace = 30;//global parameter,after gebug i found that txt Paswword  is 30 child
     foundWindow = 0;
     int txtPassword = FindSpecificWindow(LoginPopForm);
     SendMessage(txtPassword, WM_SETTEXT, 0, strPassword); 

public static int FindSpecificWindow(int intWhdrNew)
        {
            int prevChild2 = 0;
            int currChild2 = 0;

            if (intWhdrNew != 0)
            {
                try
                {

                    do
                    {

                        currChild2 = FindWindowEx(intWhdrNew, prevChild2, null, null);

                     // SendMessage(currChild2, WM_SETTEXT, 0, del.ToString());
                        //del++;
                        ChildPlace--;
                        if (currChild2 != 0)
                        {
                            if (ChildPlace == 0)
                            {
                                foundWindow = currChild2;
                                break;

                            }
                            FindSpecificWindow(currChild2) ;
                            prevChild2 = currChild2;

                        }
                    }
                    while (currChild2 != 0 && ChildPlace!=0);
                }
                catch (Exception ex)
                {

                }
            }
            else
            {

            }
            return foundWindow;
        }
Bart
  • 19,692
  • 7
  • 68
  • 77
Vladimir Potapov
  • 2,347
  • 7
  • 44
  • 71