Here is the function:
Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5
Public Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Integer, _
ByVal wCmd As Integer) As Integer
Public Declare Function GetClassName Lib "user32" (ByVal hwnd As IntPtr, ByVal lpClassName As String, ByVal nMaxCount As Integer) As Integer
Public Declare Function GetDesktopWindow Lib "user32" () As Integer
Public Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" _
(ByVal hwnd As Integer, _
ByVal lpString As String, _
ByVal cch As Integer) As Integer
Private Function FindWindowLike(ByVal hWndStart As Integer, _
ByVal WindowText As String, _
ByVal Classname As String) As Integer
Dim hwnd As Integer
Dim sWindowText As String
Dim sClassname As String
Dim r As Integer
'Hold the level of recursion and
'hold the number of matching windows
Static level As Integer
'Initialize if necessary. This is only executed
'when level = 0 and hWndStart = 0, normally
'only on the first call to the routine.
If level = 0 Then
If hWndStart = 0 Then hWndStart = GetDesktopWindow()
End If
'Increase recursion counter
level = level + 1
'Get first child window
hwnd = GetWindow(hWndStart, GW_CHILD)
Do Until hwnd = 0
'Search children by recursion
Call FindWindowLike(hwnd, WindowText, Classname)
'Get the window text and class name
sWindowText = Space$(255)
r = GetWindowText(hwnd, sWindowText, 255)
sWindowText = sWindowText.Substring(0, r)
'sWindowText = Left(sWindowText, r)
sClassname = Space$(255)
r = GetClassName(hwnd, sClassname, 255)
sClassname = sClassname.Substring(0, r)
'sClassname = Left(sClassname, r)
'Check if window found matches the search parameters
If (sWindowText Like WindowText) And _
(sClassname Like Classname) Then
'List1.AddItem(hwnd & vbTab & _
' sClassname & vbTab & _
' sWindowText)
FindWindowLike = hwnd
'uncommenting the next line causes the routine to
'only return the first matching window.
'Exit Do
End If
'Get next child window
hwnd = GetWindow(hwnd, GW_HWNDNEXT)
Loop
'Reduce the recursion counter
level = level - 1
End Function
To use it as follows:
FindWindowLike(0, "*nameurlookingfor*", "*")
This should give you a good start.