Get the handle number (HWND) of a running application

In some scenarios, it’s required to use the application’s handle (HWND) information as part of the properties used for identification . This usually happens when there are not enough available, unique or steady enough properties to help with the exact object identification.

The HWND if available, might help.

The HWND is available for a reduced set of objects, for example: In Windows based applications, for the Window and dialog classes. The example below shows how to retrieve the handle number of a running application/process in memory.


‘ This will display the HWND of the Window with a title equal to "Untitled – Notepad"

Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString

hwnd = Extern.FindWindow(vbNullString,"Untitled – Notepad")

msgbox hwnd

READ  Minimum permissions required for QuickTest Professional (QTP), Service Test (ST), Sprinter (SP) and/or Unified Functional Testing (UFT)

Leave a Comment