Find a Window
Posted by admin - Apr 1, 2008 Articles, Dani Vainstein, QTips, Windows 0 0 Views : 251 Receive Updates For This Category
Article Tools
- Print this page
- Add Comment
- Send to Friend
- Last Updated on :
Jul 16, 2011
The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.
API syntax : HWND FindWindow( LPCTSTR lpClassName, LPCTSTR lpWindowName );
Parameters :
lpClassName – [in] string that specifies the class name or a class atom The atom must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName points to a string, it specifies the window class name. If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.
lpWindowName – [in] string that specifies the window name (the window’s title). If this parameter is NULL, all window names match.
Return Value :
If the function succeeds, the return value is a handle to the window that has the specified class name and window name.
If the function fails, the return value is NULL.
Remarks : If the lpWindowName parameter is not NULL, FindWindow calls the GetWindowText function to retrieve the window name for comparison.
Extern.Declare micHWnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString
RegisterUserFunction "Browser", "Find", "fFindWindow"
RegisterUserFunction "Page", "Find", "fFindWindow"
Public Function fFindWindow( ByRef obj, ByVal className, byVal titleName, byRef hwnd )
hwnd = Extern.FindWindow( className, titleName )
If hwnd = 0 Then
fFindWindow = False
Else
fFindWindow = True
End If
End Function
bRetval = Browser( "P" ).Find( "Internet Explorer_Server", Null, hwnd )
If bRetVal Then
Reporter.ReportEvent micPass, "Exist", "Window handle --> " & hwnd
End If


