Click here to Skip to main content
15,867,594 members
Articles / Web Development / HTML
Tip/Trick

Yet Another Spy

Rate me:
Please Sign up or sign in to vote.
4.92/5 (23 votes)
28 Dec 2014CPOL2 min read 27.8K   2.1K   37   12
Find a window on the desktop, spy its properties and manipulate it.

 

Image 1

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:

Image 2

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. 

Image 3

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.

Image 4

Action toolbar

The user can take several actions on a selected window:

Image 5

  • 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.

Image 6

Image 7

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Hungary Hungary
I'm software developer & scrum master with several years of experience in project and line management.

Comments and Discussions

 
GeneralMy vote of 5 Pin
qiuqianren2-Jan-15 21:02
qiuqianren2-Jan-15 21:02 
QuestionRe: My vote of 5 Pin
Akos Mattiassich4-Jan-15 5:10
Akos Mattiassich4-Jan-15 5:10 
Can you reproduce it?
BugRe: My vote of 5 Pin
qiuqianren6-Jan-15 5:39
qiuqianren6-Jan-15 5:39 
GeneralRe: My vote of 5 Pin
Akos Mattiassich6-Jan-15 8:51
Akos Mattiassich6-Jan-15 8:51 
GeneralRe: My vote of 5 Pin
Akos Mattiassich6-Jan-15 9:03
Akos Mattiassich6-Jan-15 9:03 
GeneralRe: My vote of 5 Pin
qiuqianren6-Jan-15 18:31
qiuqianren6-Jan-15 18:31 
GeneralMy vote of 5 Pin
skyformat99@gmail.com29-Dec-14 20:48
skyformat99@gmail.com29-Dec-14 20:48 
QuestionSource Code Missing Pin
Ed Gadziemski29-Dec-14 10:39
professionalEd Gadziemski29-Dec-14 10:39 
AnswerRe: Source Code Missing Pin
Akos Mattiassich29-Dec-14 10:46
Akos Mattiassich29-Dec-14 10:46 
QuestionSource And Demo Files Missing Pin
MasterCodeon29-Dec-14 8:49
MasterCodeon29-Dec-14 8:49 
AnswerRe: Source And Demo Files Missing Pin
Akos Mattiassich29-Dec-14 9:07
Akos Mattiassich29-Dec-14 9:07 
GeneralRe: Source And Demo Files Missing Pin
MasterCodeon29-Dec-14 10:32
MasterCodeon29-Dec-14 10:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.