Private Sub btnPress_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPress.Click Dim hwnd As IntPtr hwnd = FindWindow(vbNullString, "Joe") Dim ptrChildWindows() As IntPtr = GetWindows(hwnd) For iCounter As Integer = 0 To ptrChildWindows.Length - 1 'grab the current handle to process... Dim ptrCurrent As IntPtr = ptrChildWindows(iCounter) 'get the window text... Dim sText As String = GetWindowText(ptrCurrent) TextBox2.AppendText(sText & vbCrLf) 'check to see if this is the button we are looking for... If sText = "Click" Then 'click the button to close the dialog... ClickButton(ptrCurrent) 'done deal... Exit For End If Next End Sub |