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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s