Find Window Function Generator

This will generate your Find Window functions for you! It will generate the best possible Find Window function for that window possible, because the function it generates loops through every control on that window, making sure its the window your looking for. It's always best to use a Find Window function in your coding. Just drag the magnifying glass over the window you want to create a Find Window function for. When dragging the magnifying glass, its best to drop it over the window's titlebar, otherwise make sure you drop it over the actual window, and not a control! When using your Find Window function, it will return the window's handle if the window is found, otherwise it will return 0. Here are two examples using a Find Window function.

Example #1:

In this example, our Find Window function name is "Find_Chatroom".

If Find_Chatroom() <> 0 Then
MsgBox "Chatroom found!"
Else
MsgBox "Chatroom not found!"
End If

Example #2:

In this example, our Find Window function name is "Find_Chatroom". The following code finds the window with the handle "RICHCNTL" in the window found by the Find Window function.

RICHCNTL& = FindWindowEx(Find_Chatroom(), 0, "RICHCNTL", vbNullString)

Here is an example of what a Find Window function would look like for AOL 4.0's chatroom (was generated with the Find Window Function Generator):

Public Function Find_Chatroom() As Long
AOLFrame& = FindWindow("AOL Frame25", vbNullString)
MDIClient& = FindWindowEx(AOLFrame&, 0&, "MDIClient", vbNullString)
AOLChild& = FindWindowEx(MDIClient&, 0&, "AOL Child", vbNullString)
RICHCNTL& = FindWindowEx(AOLChild&, 0&, "RICHCNTL", vbNullString)
AOLCombobox& = FindWindowEx(AOLChild&, 0&, "_AOL_Combobox", vbNullString)
AOLIcon& = FindWindowEx(AOLChild&, 0&, "_AOL_Icon", vbNullString)
For i = 1 To 3
AOLIcon& = FindWindowEx(AOLChild&, AOLIcon&, "_AOL_Icon", vbNullString)
Next i
RICHCNTL2& = FindWindowEx(AOLChild&, 0&, "RICHCNTL", vbNullString)
AOLIcon2& = FindWindowEx(AOLChild&, 0&, "_AOL_Icon", vbNullString)
AOLImage& = FindWindowEx(AOLChild&, 0&, "_AOL_Image", vbNullString)
AOLStatic& = FindWindowEx(AOLChild&, 0&, "_AOL_Static", vbNullString)
AOLGlyph& = FindWindowEx(AOLChild&, 0&, "_AOL_Glyph", vbNullString)
AOLListbox& = FindWindowEx(AOLChild&, 0&, "_AOL_Listbox", vbNullString)
AOLStatic2& = FindWindowEx(AOLChild&, 0&, "_AOL_Static", vbNullString)
AOLIcon3& = FindWindowEx(AOLChild&, 0&, "_AOL_Icon", vbNullString)
For i = 1 To 7
AOLIcon3& = FindWindowEx(AOLChild&, AOLIcon3&, "_AOL_Icon", vbNullString)
Next i
Do While (Counter <> 100) And (RICHCNTL& = 0 Or AOLCombobox& = 0 Or AOLIcon& = 0 Or RICHCNTL2& = 0 Or AOLIcon2& = 0 Or AOLImage& = 0 Or AOLStatic& = 0 Or AOLGlyph& = 0 Or AOLListbox& = 0 Or AOLStatic2& = 0 Or AOLIcon3& = 0): DoEvents
AOLChild& = FindWindowEx(MDIClient&, AOLChild&, "AOL Child", vbNullString)
RICHCNTL& = FindWindowEx(AOLChild&, 0&, "RICHCNTL", vbNullString)
AOLCombobox& = FindWindowEx(AOLChild&, 0&, "_AOL_Combobox", vbNullString)
AOLIcon& = FindWindowEx(AOLChild&, 0&, "_AOL_Icon", vbNullString)
For i = 1 To 3
AOLIcon& = FindWindowEx(AOLChild&, AOLIcon&, "_AOL_Icon", vbNullString)
Next i
RICHCNTL2& = FindWindowEx(AOLChild&, 0&, "RICHCNTL", vbNullString)
AOLIcon2& = FindWindowEx(AOLChild&, 0&, "_AOL_Icon", vbNullString)
AOLImage& = FindWindowEx(AOLChild&, 0&, "_AOL_Image", vbNullString)
AOLStatic& = FindWindowEx(AOLChild&, 0&, "_AOL_Static", vbNullString)
AOLGlyph& = FindWindowEx(AOLChild&, 0&, "_AOL_Glyph", vbNullString)
AOLListbox& = FindWindowEx(AOLChild&, 0&, "_AOL_Listbox", vbNullString)
AOLStatic2& = FindWindowEx(AOLChild&, 0&, "_AOL_Static", vbNullString)
AOLIcon3& = FindWindowEx(AOLChild&, 0&, "_AOL_Icon", vbNullString)
For i = 1 To 7
AOLIcon3& = FindWindowEx(AOLChild&, AOLIcon3&, "_AOL_Icon", vbNullString)
Next i
If RICHCNTL& And AOLCombobox& And AOLIcon& And RICHCNTL2& And AOLIcon2& And AOLImage& And AOLStatic& And AOLGlyph& And AOLListbox& And AOLStatic2& And AOLIcon3& Then Exit Do
Counter = Val(Counter) + 1
Loop
If Val(Counter) < 100 Then
Find_Chatroom& = AOLChild&
Exit Function
End If
End Function

Go Back