Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:05:28+00:00 2026-06-17T15:05:28+00:00

I have written a program that is to find a box in another program

  • 0

I have written a program that is to find a box in another program and set focus to it. Once this is done it will sendkeys and save to this box.

I am using Findwindow and FindwindowEx to locate the box, but I have a bit of an issue.
enter image description here
if you notice the windows are the same all the way down to the first TPanel. Now after that there are 3Tpanel Classes.
After 3Tpanel Classes there are multiple TttgEdit Classes.

How do I teach the program which Classes I want to select?
Here is my code thus far.

Delcare

Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As IntPtr) As Long

Private Declare Auto Function FindWindow Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As IntPtr

Private Declare Auto Function FindWindowEx Lib "user32.dll" ( _
ByVal hwndParent As IntPtr, _
ByVal hwndChildAfter As IntPtr, _
ByVal lpszClass As String, _
ByVal lpszWindow As String _
) As IntPtr

Source

    Dim hWnd As IntPtr = FindWindow("TRunprgForm", Nothing)
    If hWnd.Equals(IntPtr.Zero) Then
        Return
    End If
    cb1.Checked = True
    '--------------------instert here
    Dim hWndChild1 As IntPtr = _
    FindWindowEx(hWnd, IntPtr.Zero, "TmisinvForm", Nothing)
    If hWndChild1.Equals(IntPtr.Zero) Then
        Return
    End If

    Dim hWndChild2 As IntPtr = _
    FindWindowEx(hWndChild1, IntPtr.Zero, "TScrollBox", Nothing)
    If hWndChild2.Equals(IntPtr.Zero) Then
        Return
    End If

    Dim hWndChild3 As IntPtr = _
    FindWindowEx(hWndChild2, IntPtr.Zero, "TPageControl", Nothing)
    If hWndChild3.Equals(IntPtr.Zero) Then
        Return
    End If

    Dim hWndChild4 As IntPtr = _
    FindWindowEx(hWndChild3, IntPtr.Zero, "TTabSheet", Nothing)
    If hWndChild4.Equals(IntPtr.Zero) Then
        Return
    End If

    Dim hWndChild5 As IntPtr = _
    FindWindowEx(hWndChild4, IntPtr.Zero, "TttgCenterPanel", Nothing)
    If hWndChild5.Equals(IntPtr.Zero) Then
        Return
    End If

    Dim hWndChild6 As IntPtr = _
    FindWindowEx(hWndChild5, IntPtr.Zero, "TPanel", Nothing)
    If hWndChild6.Equals(IntPtr.Zero) Then
        Return
    End If

    Dim hWndEdit As IntPtr = _
    FindWindowEx(hWndChild6, IntPtr.Zero, "TttgDBEdit", Nothing)
    If hWndEdit.Equals(IntPtr.Zero) Then
        Return
    End If

    SetForegroundWindow(hWndEdit)

The numbers on the left hand side, hWnd, They change every time the screen is closed and opened, so I cant use them as a static number. Any help would be awesome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:05:29+00:00Added an answer on June 17, 2026 at 3:05 pm

    It looks like you want the second TPanel under the TttgCenterPanel.

    In order to do that, you can find the first TPanel (you already did this), and after that, find the TPanel that is a descendant of TttgCenterPanel, and comes after the first TPanel. You need to pass hwndChild5 into the hwndChildAfter of FindWindowEx`.

    ' .... all the stuff you did before
    
    Dim hWndChild5 As IntPtr = _
    FindWindowEx(hWndChild4, IntPtr.Zero, "TttgCenterPanel", Nothing)
    If hWndChild5.Equals(IntPtr.Zero) Then
        Return
    End If
    
    Dim hWndChild6 As IntPtr = _
    FindWindowEx(hWndChild5, IntPtr.Zero, "TPanel", Nothing)
    If hWndChild6.Equals(IntPtr.Zero) Then
        Return
    End If
    
    Dim hWndChild6Second As IntPtr = _
    FindWindowEx(hWndChild5, hWndChild6, "TPanel", Nothing)
    If hWndChild6Second.Equals(IntPtr.Zero) Then
        Return
    End If
    
    Dim hWndEdit As IntPtr = _
    FindWindowEx(hWndChild6Second, IntPtr.Zero, "TttgDBEdit", Nothing)
    If hWndEdit.Equals(IntPtr.Zero) Then
        Return
    End If
    
    SetForegroundWindow(hWndEdit)
    

    From the MSDN documentation of FindWindowEx:

    hwndChildAfter [in, optional]

    Type: HWND

    A handle to a child window. The search begins with the next child window in the Z order. The child window must be a direct child window of hwndParent, not just a descendant window.

    If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.

    This approach will work if you are trying to find the second TPanel. If they are in random order each time, this will fail.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program that uses qhttp to get a webpage. This works
I have written a program which will serialize and de-serialize, it does this fine
I have written a java program that is actually works as a gui to
I have written a c# program that calls a c++ dll that echoes the
Below I have written a sample program that I have written to learn about
I have written an ActionScript client program that tries to connect to a local
Below is a small program that I have written to count the number of
Well, i have written a simple python program that parses HTML with HTMLParser. Here
I have written a simple OpenGL program in C++ that displays a line joining
I Have a program written in VB6 that reads a long text file and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.