Create a simple Windows inspector

Create a simple Windows inspector

It takes only a handful of lines of code to create Windows inspector program, that is, an utility that lets you display the handle, the class name and the contents (Text or Caption) of the window under the mouse cursor.

To create such a program, create a small form, add a Label1 control and a Timer1 control, set the Timer’s Interval property to a small value, say 100 milliseconds, and then add this code to the form’s code module:

Private Type POINTAPI    x As Long    y As LongEnd TypePrivate Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, _    ByVal yPoint As Long) As LongPrivate Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _    (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal _    hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongPrivate Sub Timer1_Timer()    Dim lpPoint As POINTAPI    Dim wndHandle As Long    Dim wndCaption As String    Dim wndClass As String    Dim length As Long        ' get the position of the mouse cursor    GetCursorPos lpPoint    ' get the handle of the window under the mouse cursor    wndHandle = WindowFromPoint(lpPoint.x, lpPoint.y)    ' get the caption/text of the window    wndCaption = Space$(256)    length = GetWindowText(wndHandle, wndCaption, Len(wndCaption))    wndCaption = Left$(wndCaption, length)    ' get the window's class    wndClass = Space$(256)    length = GetClassName(wndHandle, wndClass, Len(wndClass))    wndClass = Left$(wndClass, length)        ' display the result in the label    Label1 = "[" & Hex$(wndHandle) & "] " & wndClass & IIf(Len(wndCaption), _        " - """ & wndCaption & """", "")End Sub

Now run the program and pass the mouse cursor over the window you want to retrieve information about.

Note that you can use this technique to peek at password-protected TextBox controls, at least those displayed by VB applications. This way to “steal” passwords works in Windows 95, 98 and NT. Fortunately, this security issue that has been fixed in Windows 2000.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as