Find a Window

Article Tools

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 :

clip_image001 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.

clip_image001[1] lpWindowName – [in] string that specifies the window name (the window’s title). If this parameter is NULL, all window names match.

Return Value :

clip_image001[2] If the function succeeds, the return value is a handle to the window that has the specified class name and window name.

clip_image001[3] 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
Previous postForcibly Close a Specified Window Next postWhat is the Last Window Opened?

Related Posts

Post Your Comment

You must be logged in to post a comment.