Eu sei que meu código não é tão elegante, mas deveria funcionar, e não funciona. Só para dar uma olhada, adiciono meus arrays a uma caixa de listagem para poder vê-los enquanto estou resolvendo o código.
cb = New CallBack(AddressOf MyCallBack)
EnumWindows(cb, 0)
Dim CadTITLE As String = ""
For Each item As String In ListBox1.Items
If item.Contains("Program Name") Then
CadTITLE = item
End If
Next
ListBox1.Items.Clear()
Dim Hwnd As IntPtr = FindWindow(Nothing, CadTITLE)
Dim hndls() As IntPtr = GetChildWindows(Hwnd)
Dim CallTITLE As String = ""
For Each hnd In hndls
If Len(GetText(hnd)) > 0 Then
ListBox1.Items.Add(GetText(hnd))
End If
Next
For Each item As String In ListBox1.Items
If item.Contains("Call No") Then
CallTITLE = item
End If
Next
Dim hwnd2 As IntPtr = FindWindowEx(Hwnd, IntPtr.Zero, nothing, CallTITLE)
If hwnd2.Equals(IntPtr.Zero) Then
MsgBox("Not Found")
Else
MsgBox("Found")
End If
De acordo com MSDN, Eu devo ser capaz de encontrar o windows pelotítulo da janela, que encontrei na variável CallTITLE (confirmado com msgbox (CallTITLE), mas ainda não está encontrando a janela filha. Deve retornar um msgbox ("encontrado") e então posso prosseguir para encontrar a caixa de texto de que preciso.
Respostas:
0 para resposta № 1Sempre, posso lutar com alguma coisa por horas e assim que faço a pergunta eu descubro. Eu estava faltando um nível. MDIClient, deveria ter detectado antes.
Dim hwnd2 As IntPtr = FindWindowEx(Hwnd, Nothing, "MDIClient", Nothing)
Dim hwnd3 As IntPtr = FindWindowEx(hwnd2, Nothing, Nothing, CallTITLE)
If hwnd3.Equals(IntPtr.Zero) Then
MsgBox("Not Found")
Else
MsgBox("Found")
End If