devxlogo

WindowDescription – Get a textual description of a window given its hWnd

WindowDescription – Get a textual description of a window given its hWnd

Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal _    hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongPrivate Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _    (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long' Return a text description of a given window' (consists of hWnd and classname, optionally followed by caption)Function WindowDescription(ByVal hWnd As Long) As String    Dim buffer As String * 256    Dim length As Long    Dim text As String    Dim classname As String        length = GetWindowText(hWnd, buffer, Len(buffer))    text = Left$(buffer, length)    length = GetClassName(hWnd, buffer, Len(buffer))    classname = Left$(buffer, length)        WindowDescription = "[" & Right$("0000000" & Hex$(hWnd), _        8) & "] " & classname    If Len(text) Then        WindowDescription = WindowDescription & " - """ & text & """"    End IfEnd Function

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist