MyWindow plugin for Take Command / TCC / TCC/LE
beta version 0.99.0 2025-04-09
Charles Dye
Purpose:
This plugin reimplements the ACTIVATE
and WINDOW
commands to better support
Windows Terminal, Console2, and ConEmu; and to add a few new features.
There is also one new function, @MYWINDOW
,
which returns information about TCC’s window; and some new utility variables
and functions to enumerate Windows 10 virtual desktops.
Installation:
To use this plugin, copy MyWindow.dll and
CDTrayMgr.exe to some
known location on your hard drive. (If you are still using the 32-bit version
of Take Command, take MyWindow-x86.dll instead
of MyWindow.dll.) Load the .DLL file with a
PLUGIN /L
command, for example:
plugin /l c:\bin\tcmd\test\mywindow.dll
If you copy these files to a subdirectory named PlugIns within your Take Command program directory, the plugin will be loaded automatically when TCC starts.
Plugin Features:
New Commands: | ||||
---|---|---|---|---|
ACTIVATE | WINDOW | |||
New Functions: | ||||
@MYWINDOW | @VDESK | |||
New Variables: | ||||
_VDESK | _VDESKS | _WINTERMEXE | _WINTERMVER |
Syntax Note:
The syntax definitions in the following text use these conventions for clarity:
BOLD CODE | indicates text which must be typed exactly as shown. |
CODE | indicates optional text, which may be typed as shown or omitted. |
Bold italic | names a required argument; a value must be supplied. |
Regular italic | names an optional argument. |
ellipsis… | after an argument means that more than one may be given. |
Examples are shown in a gray box:
rem This is an example:
window center
Some command options take an argument. These are shown with a colon between the
option and its argument: /A:
arg
If you like, you may substitute an equals sign for the colon: /A=
arg
This is handy if the arg is a filename, and you want to use tab completion to
enter the filename.
Or you can omit the colon: /A
arg
New Commands:
ACTIVATE
— Activate a window,
and optionally make changes to it.
Syntax:
ACTIVATE
/P /R "
title"
verb "
newtitle"
/P | match the " title" against program names |
/R | return focus to the original foreground window when done |
" title" | the window to activate; required |
verb | an action to alter the selected window; you may only give one |
" newtitle" | a new title to rename the window |
You must specify a title. You can use wildcards;
the first window found with a matching name will be activated. Alternatively,
you may use =
pid to search for a
window belonging to the specified program id. The pid
may be in decimal, or hexadecimal with a leading 0x
.
If you know the window’s handle, you can also specify that with the
syntax HWND==
hwnd. Note that there
are two equals signs after the HWND
. The
hwnd may be in decimal, or hexadecimal with a
leading 0x
. This syntax is not supported by TCC’s
ACTIVATE
.
The following verbs are supported; you may only use one at a time:
MIN | minimize the window (use RESTORE bring it back) | |
MAX | maximize the window (use RESTORE to return it to its previous size) | |
HIDE | hide the window (use RESTORE to make it visible again) | |
RESTORE | restore the window to its normal size and make it visible | |
CLOSE | close the window | |
DISABLE | disable mouse and keyboard input to the window (use ENABLE to fix it) | |
ENABLE | re-enable mouse and keyboard input to a window crippled by DISABLE | |
TOPMOST | display the window above all non-topmost windows (use NOTOPMOST to fix it) | |
NOTOPMOST | make a TOPMOST window display normally again | |
TOP | move the window to the front | |
BOTTOM | move the window behind all other windows | |
POS= x, y, w, h | move and resize the window | |
POS= x, y | † | move the window to the specified coordinates |
SIZE= w, h | † | resize the window without moving it |
ICON= file | attempt to extract an icon from file and apply it to the window | |
TRANS= n | set the window transparency; n is 0 (invisible) to 255 (opaque) | |
FLASH= type, count | flash the window; args as per FLASHWINFO | |
TRAY | hide the window, and show its icon in the system tray (use RESTORE to undo) | |
CENTER | center the window in its current monitor | |
ALIGN= n, M | † | align the window relative to a monitor’s edges |
INFO | † | do not activate the window, but display a bunch of information about it |
You can use "
newtitle"
to rename the window. The new title must be quoted; otherwise it will
be interpreted as a verb.
In the POS
and SIZE
verbs, the
x and y arguments are signed integers;
w and h are unsigned. Any of these may
be replaced with an asterisk to keep the current value. For example, POS=*,*,400,150
will resize the window to 400×150 pixels without changing its position.
TRAY
mode will only work if
(a) TCC is running elevated, and (b) CDTrayMgr.exe
is available. You can put CDTrayMgr.exe in
the plugin’s directory, in Take Command’s install directory, or
in any directory in the search path.
ALIGN=
n,
M
moves the window relative to a monitor. n is required;
possible values are:
7: top left | 8: top center | 9: top right |
4: left center | 5: center | 6: right center |
1: bottom left | 2: bottom center | 3: bottom right |
The monitor number M is optional. If is zero or greater than the number of monitors, it defaults to the primary monitor. If you do not specify a monitor number, the window will be aligned on whichever monitor it currently occupies.
• Note: This command has been completely reimplemented to better support Windows Terminal, Console2, and ConEmu.
• Note: The SIZE
verb, the POS
verb with only two arguments, and the ALIGN
and INFO
verbs, are all incompatible with TCC’s internal
ACTIVATE
command. To be compatible, use POS
with
all four arguments, using *
for any values you don’t
want to change.
The HWND==
hwnd syntax is also new,
and is not compatible with TCC.
The /P
option also is not supported by TCC.
WINDOW
— Control TCC’s
display window.
Syntax:
WINDOW
verb "
newtitle"
verb | an action to alter the window; you may only give one |
" newtitle" | a new title to rename the window |
MIN | minimize the window (use RESTORE bring it back) | |
MAX | maximize the window (use RESTORE to return it to its previous size) | |
HIDE | hide the window (use RESTORE to make it visible again) | |
RESTORE | restore the window to its normal size and make it visible | |
TOPMOST | display the window above all non-topmost windows (use NOTOPMOST to fix it) | |
NOTOPMOST | make a TOPMOST window display normally again | |
TOP | move the window to the front | |
BOTTOM | move the window behind all other windows | |
POS= x, y, w, h | move and resize the window | |
POS= x, y | † | move the window to the specified coordinates |
SIZE= r, c | resize the console screen buffer | |
ICON= file | attempt to extract an icon from file and apply it to the window | |
TRANS= n | set the window transparency; n is 0 (invisible) to 255 (opaque) | |
FLASH= type, count | flash the window; args as per FLASHWINFO | |
TRAY | hide the window, and show its icon in the system tray (use RESTORE to undo) | |
CENTER | center the window in its current monitor | |
ALIGN= n, M | † | align the window relative to a monitor’s edges |
DETACH | detach a Take Command tab to a standalone console window | |
VDESKTOP= id | move TCC’s console window to a different virtual desktop | |
INFO | † | do not activate the window, but display a bunch of information about it |
VDESKLIST | † | list virtual desktops; does not affect TCC’s window |
TRAYLIST | † | list windows in the tray, i.e. windows managed by CDTrayMgr.exe. |
You can use "
newtitle"
to rename the window. The new title must be quoted; otherwise it will
be interpreted as a verb.
In the POS
verb, the
x and y arguments are signed integers;
w and h are unsigned. Any of these may
be replaced with an asterisk to keep the current value. For example, POS=*,*,400,150
will resize the window to 400×150 pixels without changing its position.
In the SIZE
verb,
r and c are the
number of rows and columns for the console screen buffer — both
unsigned integers. You cannot make the buffer smaller than the visible viewport.
r must also be between 5 and 9999 rows;
c must be between 20 and 512 columns.
TRAY
mode will only work if
(a) TCC is running elevated, and (b) CDTrayMgr.exe
is available. You can put CDTrayMgr.exe in
the plugin’s directory, in Take Command’s install directory, or
in any directory in the search path.
ALIGN=
n,
M
moves the window relative to a monitor. n is required;
possible values are:
7: top left | 8: top center | 9: top right |
4: left center | 5: center | 6: right center |
1: bottom left | 2: bottom center | 3: bottom right |
The monitor number M is optional. If is zero or greater than the number of monitors, it defaults to the primary monitor. If you do not specify a monitor number, the window will be aligned on whichever monitor it currently occupies.
VDESKTOP=
id
has a very limited usefulness: it can only move TCC’s own console
window. It cannot move Take Command’s window, or Windows Terminal’s
window, or Console2’s window. It cannot move another program’s
console window, e.g. when TCC is a child process of the console
window’s owner. It can only move its own window. Sorry.
Microsoft’s documented IVirtualDesktopManager
API is lame.
The desktop id can be either a number 1 to
n for the first, second, third, etc. virtual desktop; or else
a name, e.g. VDESKTOP="Desktop 2"
.
Virtual desktops were introduced in Windows 10; this feature will not work in earlier versions of Windows.
The VDESKLIST
and TRAYLIST
verbs are mostly for my own use in debugging. I am documenting them on the
chance that they might be useful to someone else. VDESKLIST
lists
Windows 10 virtual desktops; TRAYLIST
lists windows currently managed
by CDTrayMgr.exe. Neither one
does anything to TCC’s window. They just dump info to standard output.
• Note: This command has been completely reimplemented to better support Windows Terminal, Console2, and ConEmu.
• Note: The POS
verb with only two arguments, and the ALIGN
, INFO
,
VDESKLIST
, and TRAYLIST
verbs, are all incompatible
with TCC’s internal WINDOW
command. To be compatible, use
POS
with all four arguments, using *
for any value
you don’t want to change.
New Functions:
@MYWINDOW
— Returns
information about TCC’s display window.
Syntax:
%@MYWINDOW[
n]
n | which information to return: |
0 - the window’s handle in hex with a leading 0x | |
1 - the window’s handle in hex, no leading 0x | |
2 - the window’s handle in decimal | |
3 - the display window type as an integer | |
4 - the display window type as a string | |
8 - the window’s current title | |
9 - the window’s class name | |
10 - the window’s position, as per @WINPOS : top, left, bottom, right | |
11 - the window’s size, as per @WINSIZE : height, width | |
12 - the window’s size and position, in POS= args order: left, top, width, height | |
13 - the window’s current state, as per @WINSTATE | |
14 - the window’s state, as a string | |
15 - nonzero if the window is currently in the tray, zero if not | |
16 - the monitor on which the window appears | |
17 - the process ID (PID) of the program that created the window (hex, with a leading 0x ) | |
18 - the thread ID of the thread that created the window (hex, with a leading 0x ) | |
19 - the filename of the program that created the window | |
20 - the name of the window’s virtual desktop | |
21 - the GUID of the window’s virtual desktop | |
22 - the handle of the tray manager’s window, or 0 if it is not loaded |
If n is not specified, it defaults to 0.
@VDESK
— Returns the name
or GUID of a virtual desktop.
Syntax:
%@VDESK[
index,
info]
index | the number of the virtual desktop; 0-based |
info | which info to return: |
0 - the virtual desktop’s name (default) | |
1 - the virtual desktop’s GUID |
This feature requires Windows 10 or later. If virtual desktops are not supported,
if index ≥ _VDESKS
,
or if any error occurs, this function returns an empty string.
If the specified virtual desktop does not have a name, @VDESK
returns
a default name of “Desktop n
”.
for /l %i in ( 0, 1, %@dec[%_vdesks] ) echo %i: %@vdesk[%i] %@vdesk[%i,1]
New Variables:
_VDESK
— Returns the name of
the current virtual desktop.
Syntax:
%_VDESK
This feature requires Windows 10 or later. If virtual desktops are not supported
or any other error occurs, _VDESK
returns an empty string.
_VDESKS
— Returns the number
of virtual desktops found.
Syntax:
%_VDESKS
This feature requires Windows 10 or later. If virtual desktops are not supported
or any other error occurs, _VDESKS
returns 0
.
_WINTERMEXE
— Returns the
filename used to start Windows Terminal.
Syntax:
%_WINTERMEXE
This feature requires Windows 10 or later. If TCC is not running in
Windows Terminal, _WINTERMEXE
returns an empty string.
• Note: I may change or remove this variable in a later version.
_WINTERMVER
— Returns the
version of Windows Terminal.
Syntax:
%_WINTERMVER
The version number will be returned as four values separated by periods.
This feature requires Windows 10 or later. If TCC is not running in
Windows Terminal, _WINTERMVER
returns 0
.
• Note: I may change or remove this variable in a later version.
The Tray Manager:
CDTrayMgr.exe is a separate program which
manages icons in the system tray. It’s only needed if you use the
TRAY
verb in ACTIVATE
or
WINDOW
. The tray manager creates icons
in the tray, monitors windows and automatically removes the icons for any
which close, and receives messages from its tray icons. When the user
double-clicks on one of its tray icons, the tray manager restores the window
and removes the icon. CDTrayMgr.exe unloads
itself automatically after ten minutes of disuse. A single instance of
CDTrayMgr.exe can be shared between multiple
shells.
CDTrayMgr.exe needs to run elevated, so
TCC must be running elevated for TRAY
to work.
You can put CDTrayMgr.exe in the plugin’s directory, in Take Command’s install directory, or in any directory in the search path.
CDTrayMgr.exe’s own tray icon is by popo2021. I found it at https://flaticon.com.
Startup Message:
This plugin displays an informational line when it initializes. The
message will be suppressed in transient or pipe shells. You can disable it
for all shells by defining an environment variable named NOLOADMSG
,
for example:
set /e /u noloadmsg=1
Changes:
Version: | Date: | Changes: |
---|---|---|
0.99.0 | 2025-04-09 | Added TRAYLIST to dump windows managed by
CDTrayMgr.exe. Documented VDESKLIST , which has been there for a
while now but never made it into the docs. Added @MYWINDOW[22] to return CDTrayMgr.exe’s
window, or 0 if it isn’t found. WINDOW INFO : Also show version information for the program file, if available. |
0.98.9 | 2024-12-06 | Adds /M , which attempts to center the mouse on
the window (undocumented, and may go bye-bye). Adds ACTIVATE /P , which tries to
match the “title” against program names. |
0.98.8.3 | 2024-12-03 | AW_FindWindowByTitleOrPid(): save the console window’s title before a title search, and restore it afterwards. |
0.98.8.2 | 2024-12-02 | WINDOW TRANS= n:
do not screw up color-key transparency. |
0.98.8.1 | 2024-11-27 | Changes to _WINTERMVER . |
0.98.8 | 2024-11-26 | Bug fixes; minor code and feature improvements. |
0.98.7.5 | 2024-11-25 | Added support for window on all vdesktops. |
0.98.7.4 | 2024-11-19 | Adds _WINTERMEXE
and _WINTERMVER , on a trial basis. I may change or remove these
in a later version. _WINTERMVER in particular is a vile, steaming crock of shit. |
0.98.7.3 | 2024-11-13 | Adds WS_EX_NOACTIVATE to the Horrible
window styles. No changes to the code. |
0.98.7.2 | 2024-11-08 | Corrrected the value for PLUGIN_BUFFER_MAX
(it’s really 32K bytes, not 32K characters.) As this define is not currently used anywhere in this
plugin, the change does not fix any actual bug. |
0.98.7.1 | 2024-11-01 | Added a perfectly Horrible workaround to get the current
VDesk guid on Windows 10 systems, where is it not available via the registry. Added @MYWINDOW[21] to return the GUID of the window’s current
virtual desktop. |
0.98.7 | 2024-10-22 | Added _VDESK ,
_VDESKS , and @VDESK . |
0.98.6.1 | 2024-10-02 | ParseInt() now supports octal with a leading 0o . |
0.98.6 | 2024-09-18 | Added WINDOW VDESKTOP ,
only for the very limited case of TCC’s own console window. This will not work for Take Command,
Windows Terminal, Console2, etc. windows, or in cases where TCC does not own the console window,
e.g. when TCC is a child process of the console window’s owner. |
0.98.5.1 | 2024-09-17 | WINDOW INFO / ACTIVATE INFO
now quotes the virtual desktop name. ALIGN with no monitor specified now aligns the window on whichever monitor it currently occupies. |
0.98.5 | 2024-09-16 | CENTER now centers the window
on its current monitor (for compatibility with TCC v33). WINDOW INFO attempts to display the name of the window’s current virtual desktop, and
@MYWINDOW[20] tries to return it. |
0.98.4.3 | 2024-08-01 | Added an error message for the VDESKTOP option.
I don’t believe it is possible to make this option work reliably as documented; TCC’s does not work for me.
Microsoft’s documented IVirtualDesktopManager is flaccid by design, and the undocumented API seems to
change with each new release of Windows. |
0.98.4.1 | 2024-06-07 | Added info on the parent/owner window’s position and
size to WINDOW INFO . |
0.98.4 | 2024-06-07 | Bug fix for AW_GetProcessFilename() : compare Windows
major version against 10, not zero. Added @MYWINDOW modes 17, 18, 19 to return the window’s Process ID, thread ID, and process
filename. |
Status and Licensing:
Consider this beta software. It may well have issues. Try it at your own risk. If you find a problem, you can report it in the JP Software support forum.
MyWindow is currently licensed only for testing purposes. I may make binaries and source code available under some free license once I consider it ready for use.
Download:
You can download the current version of this plugin from https://charlesdye.net/dl/mywindow.zip.