This will search for Notepad.
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Sub Command1_Click()
Dim hWin As Long
hWin = FindWindowEx(0, 0, "Notepad", vbNullString)
Do While hWin = 0
DoEvents
hWin = FindWindowEx(0, 0, "Notepad", vbNullString)
Loop
MsgBox "Notepad is open"
End Sub
The 2nd last argument specifies the classname, and the last argument is the window title. If you "don't care" what the title or class name is, pass vbNullString. In this case I passed vbNullString because the title will vary, whereas the classname is constant.