2014-12-09 9 views
-1

나는 윈도우 폼 팝업에서 textBox의 사용자 이름과 암호 및 버튼을 찾아야합니다.같은 클래스의 창을 찾는 방법 User32.dll winForm

PopUp ID를 찾았지만 같은 텍스트를 가진 element/child 내에서 textBox를 찾았습니다. 필요한 특정 텍스트 상자를 찾을 수 없습니다. 이해할 이미지를보십시오.

나는 같은 학급에 8 명의 아이가 있으며, 각각은 내가 필요로하는 것과 같은 엘레멘트를 가지고있다. 파라 메 트 후에 자식에 의해 발견되었지만 실패했다.

 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); 

이 이미지를 참조하십시오

enter image description here

+0

아니, 난 사용자 이름과 암호를 눌러 로그인을 삽입하려고 button.But이 여기에 내가 txtBox의 ID를 찾아야합니다. –

+0

오케이, 잘못하면 사과드립니다. 나는 이런 종류의 일에 오히려 편집증 적이다. 내가 아는 누군가에게 나쁜 일이 일어났다. – RenniePet

답변

0

나는 모든 어린이 넘어 내가 필요한 것을 발견 기능을 내장.

필자는 FindSpecificWindow를 gebuged하고 (SendMessage)를 사용하여 텍스트를 설정하고 이와 같이 변경된 텍스트로 요소의 위치를 ​​찾았습니다. 여기

그것이 :

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; 
     }