LISTWINDOWS — List windows, using a user-defined format string.

Syntax:
LISTWINDOWS /C:class /E:prog /F:"fmt" /I /L:n /O:flags /P /R /T:title /V /W:win

/C:classfilter top-level windows by class name (supports wildcards)
/E:proglist windows created by the specified program (name or PID)
/F:"fmt"format string
/Iinvisible windows only
/L:nline length
/O:flagssort windows
/Ppage output
/Rlist child windows recursively
/T:classfilter top-level windows by title (supports wildcards)
/Vvisible windows only
/W:winlist child windows of the specified window (title or handle)

With /E:prog, this command lists all top-level windows created by the specified program. With /W:win, this command lists all child windows of the specified window. With neither /E: nor /W:, it lists all top-level windows.

If no /F:"fmt" is given, the default format string is "$08h:  $v  $-25c  \u201c$t\u201d" to list each window’s handle, visibility, class name, and title.


/E:prog lists windows created by a specific program. The prog may be either a process ID or a filename. If it’s a process ID, you can enter it in decimal, or hexadecimal with a leading 0x. Only windows created by that one specific process will be listed.

If it’s a filename, it much match exactly (no wildcards). You can enter either a base name (e.g. /E:tcc.exe ) or a complete pathname (e.g. /E:c:\bin\tcmd34\tcc.exe ). This syntax can match multiple processes — you might have multiple copies of the same program running at once. If you try to combine a process ID with a filename, the process ID wins; the filename will be ignored.


/O: can sort by several criteria. The available sort keys are:

Csort by window class
Psort by process ID
Rsort by thread ID
Ssort by styles word
Tsort by title
Vsort by visibility
Wsort by window handle
Xsort by extended styles word
-reverses the following key

These can be combined, e.g. /O:CT to sort by window class name first, then by title where two windows have the same class. If you do not give any /O:flags, the default is to sort by window handles. To disable sorting altogether, you can use /OU.

Format String:

These are the tokens supported in the format string:

Token:Gives:
$cthe window’s class name
$hthe window handle
$pthe window owner’s pid
$sthe window’s styles word
$tthe window’s title
$vV for visible or I for not visible
$xthe window’s extended styles word
$Hthe window’s height
$Nthe name of the program which created the window
$Othe handle of the window’s owner window
$Pthe handle of the window’s parent window
$Vthe name of the window’s virtual desktop, if available
$Wthe window’s width
$Xthe window’s left edge
$Ythe window’s top edge
$$dollar sign

You can use modifiers between the dollar sign and the letter to change how the value is displayed:

Modifier:Changes the value:
-left-aligns a field
0zero-pads a numeric field
#uses decimal instead of hex
!forces uppercase
,forces lowercase
widthset the field’s width (decimal only)

A few character escapes are also supported:

Escape:Gives:
\eASCII escape
\kbackquote
\nnewline
\ppercent sign
\qdouble quote
\rcarriage return
\ttab
\\backslash
\unnnnUnicode character, up to U+FFFF
\UnnnnnnUnicode character, up to U+10FFFF