PopupFix plugin for TCC and TCC/LE

Version 1.3.0     2014-10-29

Charles Dye

Purpose:

This plugin is intended to solve problems with popup windows in TCC, particularly in the Console2 tabbed console wrapper. If PgUp doesn’t work in TCC under Console2, installing PopupFix may fix the problem. If you are not having issues with invisible 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 using the 64-bit version of TCC, take PopupFix-x64.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 internal variables: _CONEMU, _CONSOLE2, _TCMDTAB

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 (N)
/Drestore the original plugin defaults
/F:focusreset focus when a dialog is closed (Console2)
/L:loadload plugin only if Console2 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 to center only popups which appear off the visible screen. If you set center to A, PopupFix will center all popup windows which it discovers. 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). The default is N, to center as needed. This option may be useful if popups appear far away from the main window, e.g. on the wrong monitor in a multi-monitor system.

/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). Only the first letter is significant; the default is Console2.

/L: If you set this option to Yes, the plugin will not load unless it detects the Console2 terminal emulator. 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.

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.

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.

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.

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 trumps 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 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 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:


v1.0.02013-04-24initial release
v1.0.12013-04-27minor cosmetic fix
v1.0.22013-05-02fix for TCC occasionally un-hiding its window after Console2 has hidden it
v1.0.32013-05-15ghastly workaround for console windows STARTed from a Console2 tab being misidentified as belonging to Console2 (and automatically hidden)
v1.0.42013-05-16improved Console2 detection
v1.1.02013-05-22reworked /C: to have three values
v1.2.02013-06-17tweaks to window-offscreen detection
v1.2.12013-09-23fix for problem with focus resetting when popups are opened and closed in quick succession
v1.2.22014-07-31recognize Take Command 16+ main window (“XTPMainFrame” class)
v1.3.02014-10-23changes for TCC v17 compatibility

Status and Licensing:

This software is copyright © 2014, 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://prospero.unm.edu/dl/popupfix.zip or ftp://prospero.unm.edu/popupfix.zip.