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 CODEindicates text which must be typed exactly as shown.
CODEindicates optional text, which may be typed as shown or omitted.
Bold italicnames a required argument; a value must be supplied.
Regular italicnames 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:centercenter popup windows   (All)
/Drestore the original plugin defaults
/F:focusreset focus when a dialog is closed   (Console2)
/L:loadload plugin only if Console2 or Windows Terminal is detected   (No)
/Rrestore default options from the registry
/Ssave 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:


/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 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_CenterAlwaysCenterDWORD0 as needed, 1 always, 2 beside window0
PopupFix_Restore_FocusRestoreFocusDWORD0 never, 1 always, 2 Console2 and Windows Terminal only2
PopupFix_Console2_OnlyConsole2OnlyDWORD0 no, else yes0

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 historyPopupPgUp or PgDn keys
Directory historyPopupCtrl-PgUp or F6 keys
Filename completionPopupF7 key
Extended directory searchPopupCD, CDD, PUSHD, etc.
Text line selectionPopup@SELECT function
TCC configurationDialogOPTION command
LIST open filenameDialogLIST command
LIST find textDialogF or Ctrl-F keys in LIST
LIST goto line numberDialogG key in LIST
Command assistanceDialogsmany 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.22024-04-30Windows Terminal detection is faster, and is done more frequently.
1.4.12024-04-24Numerous changes, mostly to the detection and handling of Windows Terminal.
1.4.0.12024-03-13Minor tweaks to ForceForegroundWindow().
1.4.02023-11-28Added 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.12021-09-21Switched 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.02014-10-23changes for TCC v17 compatibility
1.2.22014-07-31recognize Take Command 16+ main window (“XTPMainFrame” class)
1.2.12013-09-23fix for problem with focus resetting when popups are opened and closed in quick succession
1.2.02013-06-17tweaks to window-offscreen detection
1.1.02013-05-22reworked /C: to have three values
1.0.42013-05-16improved Console2 detection
1.0.32013-05-15ghastly workaround for console windows STARTed from a Console2 tab being misidentified as belonging to Console2 (and automatically hidden)
1.0.22013-05-02fix for TCC occasionally un-hiding its window after Console2 has hidden it
1.0.12013-04-27minor cosmetic fix
1.0.02013-04-24initial 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.