Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Yet Another Spy

0.00/5 (No votes)
28 Dec 2014 1  
Find a window on the desktop, spy its properties and manipulate it.

 

Introduction

MySpy enumerates windows on the desktop and lists them in a tree. You can see some properties of a window represented by a node in the tree: Title (window text), Class name, PID, HWND or the path of the Module. And more in the info pane. For example the properties of the main window of MySpy:

Title          : MySpy
HWND           : 01051258
Class Name     : MySpy_MainFrame
Class Style    : CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS
Module Name    : N/A
Rect           : (365, 167)-(1309, 695) 944x528
Window Style   : WS_BORDER | ... | WS_TILEDWINDOW | WS_VISIBLE = 349110272
Window ExStyle : WS_EX_OVERLAPPEDWINDOW |...| WS_EX_WINDOWEDGE = 00000264
Process ID     : 00000644
Thread ID      : 00006988
Window ID      : 1351813779

The flags are decoded, so you can copy the constants directly into your code.

Main toolbar: filter windows and choose display mode

The main toolbar contains the following buttons:

The functions left to right:

  • Set MySpy topmost
  • Refresh window tree
  • Filter buttons (filters can be used combined eg. visible & parent windows)
    • visible windows
    • invisible windows
    • parent windows
    • child windows
  • Display numbers in hex
  • Highlight selected window
  • Find

Find window by text or by mouse

To find a window in the tree is possible by text or by mouse also. The text can contain any part of informations displayed on a node: Title, Class, PID, HWND or the path of the Module. This tool is very handy if you want to find a control, which is hidden, or if its size became 0 for some reason. 

If you can see the window on the desktop, but you can't find it in the tree, you can choose the "By Mouse" tab. While draging the cross-hairs over a window it will be immediatelly selected in the tree, by releasing the mouse button, MySpy will be activated and the last found window will be selected in the tree.

Action toolbar

The user can take several actions on a selected window:

  • Show
  • Hide
  • Enable
  • Disable
  • Left click
  • Right click
  • Left double-click
  • Right double-click
  • Minimize
  • Maximize
  • Close

Advanced actions

This part of the program can break and cause the manipulated program to malfunction, please use it only if you know exactly what you do!

With the advanced actions toolbar you can send or post messages, set text and transparency of the selected window. The message id can be selected by the combobox or can be given also as a number.

Background

I wrote this program long time ago, but it can be used nowadays too. It helped me to detect bugs, develop tricky controls and impress colleagues they don't even know about WinApi :)

Points of Interest

WinApi is an "old" technology, but it's worth to know about it.

History

01/01/2015 3.0  Some more information, warning and document formatting
29/12/2014 2.0 Source and exe links are corrected.
29/12/2014 1.0 Initial version.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here