PopupFix plugin for TCC and TCC/LE
Version 1.4.2 2024-04-30
Charles Dye
Purpose:
This plugin is intended to solve problems with popup windows in TCC, particularly in the Console2 tabbed console wrapper and in Microsoft’s own Windows Terminal. If PgUp doesn’t work in TCC under Console2, installing PopupFix may fix the problem. If you are not having issues with popup windows, this plugin serves no purpose.
PopupFix waits for TCC to create a command history, directory history, or filename completion window, or a system dialog box. When one of these popup windows appears, PopupFix tries to fix problems that would render it invisible: appearing off-screen or popping up underneath other windows.
Installation:
To use this plugin, copy PopupFix.dll to
some known location on your hard drive. (If you are still using the 32-bit
version of TCC, take PopupFix-x86.dll instead of
PopupFix.dll.) Load the file with a
PLUGIN /L
command, for example:
plugin /l c:\bin\tcmd\test\popupfix.dll
If you copy this file to a subdirectory named PlugIns within your TCC program directory, the plugin will be loaded automatically when TCC starts.
Plugin Features:
New Command: | ||||
---|---|---|---|---|
POPUPFIX | ||||
New Variables: | ||||
_CONEMU | _CONSOLE2 | _TCMDTAB | _WINTERM |
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. |
New Command:
POPUPFIX
— Displays or changes
plugin options.
Syntax:
POPUPFIX
/C:
center /D /F:
focus /L:
load /R /S
/C: center | center popup windows (All) |
/D | restore the original plugin defaults |
/F: focus | reset focus when a dialog is closed (Console2) |
/L: load | load plugin only if Console2 or Windows Terminal is detected (No) |
/R | restore default options from the registry |
/S | save the current options to the registry as the new defaults |
All options may be combined except for /D
and /R
.
If you specify multiple options, they are applied in this order:
- The original (
/D
) or saved (/R
) defaults are restored. - Any changes made with
/C:
,/F:
, or/L:
are applied. - If
/S
was specified, the new settings are saved to the registry.
/C:
The default behavior is A
to center all
popup windows. If you set center to N
,
PopupFix will center only popups which appear off the visible screen. If
center is W
, PopupFix will instead
try to move the popup window alongside the main window; if that fails
(because there isn’t enough room near the main window), the plugin
will either center the popup (if it’s off-screen) or leave it alone (if
it’s already on-screen). Only the first letter is significant.
/F:
Enable this option if you have problems with the focus
being moved to unrelated programs after you close a TCC dialog. Possible
values are Never
, Always
, or Console2
(reset focus only when running in Console2 or Windows Terminal). Only the
first letter is significant; the default is Console2
.
Note that the Console2
setting controls both Console2 and
Windows Terminal. (Both seem to have similar issues with restoring focus
after a popup dialog closes.)
/L:
If you set this option to Yes
, the plugin
will not load unless it detects either Console2 or Windows Terminal. The
default is No
.
/R:
If you use /R
to reset the plugin to the
user’s defaults, default values will be read from the registry only. Any
POPUPFIX_* environment variables will be ignored.
New Internal Variables:
_CONEMU
— ConEmu terminal
emulator status.
Syntax:
%_CONEMU
If TCC is running in ConEmu-Maximus5,
this variable returns a nonzero value. If ConEmu is not detected, it returns
0
.
_CONSOLE2
— Console2
terminal emulator status.
Syntax:
%_CONSOLE2
If the plugin has found that TCC is running in
Console2,
this variable returns a nonzero value. If Console2 was not detected, it returns 0
.
_TCMDTAB
— Take Command tab
status.
Syntax:
%_TCMDTAB
If TCC is running in a Take Command tab window, this variable returns a
nonzero value. If Take Command was not detected, it returns 0
.
_WINTERM
— Windows Terminal
status.
Syntax:
%_WINTERM
If TCC is running in a Windows Terminal
window, this variable returns a nonzero value. If Windows Terminal was not detected,
it returns 0
.
Registry Use:
PopupFix looks for default options in these locations when it starts up, in this order:
- Environment variables
- Registry key HKEY_CURRENT_USER\Software\JPPlugins\PopupFix
- Registry key HKEY_LOCAL_MACHINE\Software\JPPlugins\PopupFix
Environment variables override registry values; HKEY_CURRENT_USER beats HKEY_LOCAL_MACHINE. The values the plugin looks for are:
Environment variable: | Registry entry: | Type: | Usage: | Default: |
PopupFix_Always_Center | AlwaysCenter | DWORD | 0 as needed, 1 always, 2 beside window | 0 |
PopupFix_Restore_Focus | RestoreFocus | DWORD | 0 never, 1 always, 2 Console2 and Windows Terminal only | 2 |
PopupFix_Console2_Only | Console2Only | DWORD | 0 no, else yes | 0 |
POPUPFIX /S
saves settings only to
HKEY_CURRENT_USER, not to HKEY_LOCAL_MACHINE.
If you set the Console2-only option with POPUPFIX /L:YES /S
and
you don’t have Console2 or Windows Terminal installed, changing the
setting back may seem like a puzzle — you can’t use the
POPUPFIX
command without loading the plugin, and you can’t
load the plugin without changing the saved options! One way to solve the problem
is to override the registry value with an environment variable:
set popupfix_console2_only=0
plugin /l popupfix.dll
popupfix /s
unset popupfix_console2_only
Another solution would be to remove or zero the offending registry entry with RegEdit, or with a command like:
echo %@regset[hkcu\software\jpplugins\popupfix\console2only,reg_dword,0]
Popup Windows:
Some of the popup windows and dialog boxes that this plugin will force to the front, and possibly move:
Function: | Type: | Key or Command: |
Command history | Popup | PgUp or PgDn keys |
Directory history | Popup | Ctrl-PgUp or F6 keys |
Filename completion | Popup | F7 key |
Extended directory search | Popup | CD , CDD , PUSHD , etc. |
Text line selection | Popup | @SELECT function |
TCC configuration | Dialog | OPTION command |
LIST open filename | Dialog | LIST command |
LIST find text | Dialog | F or Ctrl-F keys in LIST |
LIST goto line number | Dialog | G key in LIST |
Command assistance | Dialogs | many commands |
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:
1.4.2 | 2024-04-30 | Windows Terminal detection is faster, and is done more frequently. |
1.4.1 | 2024-04-24 | Numerous changes, mostly to the detection and handling of Windows Terminal. |
1.4.0.1 | 2024-03-13 | Minor tweaks to ForceForegroundWindow(). |
1.4.0 | 2023-11-28 | Added support for Windows Terminal. Use ShowCmdHelp()
to display help text. CenterPopups defaults to CENTER_ALWAYS . Moved the arg parser out to
ParseArgs.cpp. Updated the plugin’s web site. Other minor code tweaks. |
1.3.0.1 | 2021-09-21 | Switched the .dll names; now PopupFix.dll is the 64-bit build. Tweaks to the version info structure. Minor code cleanup. No changes to plugin operation. |
1.3.0 | 2014-10-23 | changes for TCC v17 compatibility |
1.2.2 | 2014-07-31 | recognize Take Command 16+ main window (“XTPMainFrame” class) |
1.2.1 | 2013-09-23 | fix for problem with focus resetting when popups are opened and closed in quick succession |
1.2.0 | 2013-06-17 | tweaks to window-offscreen detection |
1.1.0 | 2013-05-22 | reworked /C: to have three values |
1.0.4 | 2013-05-16 | improved Console2 detection |
1.0.3 | 2013-05-15 | ghastly workaround for console windows STARTed from a Console2 tab being misidentified as belonging to Console2 (and automatically hidden) |
1.0.2 | 2013-05-02 | fix for TCC occasionally un-hiding its window after Console2 has hidden it |
1.0.1 | 2013-04-27 | minor cosmetic fix |
1.0.0 | 2013-04-24 | initial release |
Status and Licensing:
This software is copyright © 2024, Charles Dye.
The binaries and documentation for this plugin may be freely redistributed without restriction. I make no guarantee and give no warranty for its operation. If you find a problem, you can report it in the JP Software support forum.
Download:
You can download the current version of the plugin from http://charlesdye.net/dl/popupfix.zip.