terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Quake window responds poorly to `SW_MINIMIZE` coming through ConPTY

Open arqalite opened this issue 7 months ago • 9 comments

Windows Terminal version

1.22.10731.0

Windows build number

10.0.19044.0

Other Software

No response

Steps to reproduce

Start Windows Terminal with the following command: wt.exe -w _quake pwsh -window minimized

Expected Behavior

The Terminal opens in Quake mode, then minimizes itself. No other windows appear on the screen.

Actual Behavior

The Terminal does open in Quake mode, minimized. But then there is a very small (presumably empty) window in the bottom-left corner of the screen.

Image

This happens on both Windows 10 Enterprise LTSC and Windows 11 Pro. My assumption is that Terminal needs this window to exist, but it's supposed to be outside the screen boundary?

arqalite avatar Apr 08 '25 07:04 arqalite

Are you by chance using any shell modifications/?

DHowett avatar Apr 09 '25 21:04 DHowett

I do not have any shell modifications on either device, as far as I can tell. That said, this does not occur with CMD, so I tried reinstalling PowerShell but the window still appears.

Running PowerShell in Console Host doesn't trigger this, so I'm unsure if it's a PowerShell issue or a Terminal issue.

arqalite avatar Apr 13 '25 10:04 arqalite

I'm experiencing this, too. Though I'm starting wt from task scheduler on login. I'm using %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe -w _quake pwsh -nologo -window minimized -NoExit -Command "& { . $env:OneDrive\Dokumente\PowerShell\profile.ps1 }" to launch.

If I have the quake mode window visible and then single click the grey area then something like a program's system menu pops up in the top left corner of my desktop - it'S the same menu I get when I right click in the free space of the wt tab bar

Image If the quake mode window is not visible and I single click the grey area the nothing seems to happen. If I double click it, then the quake mode windows opens and the grey area vanishes. I can the hide the quake mode window with the key binding of my choice

This behaviour was not always so. In one of the older releases this grey area wasn't there - or if it was it was outside the visible desktop area. That should have been about 6 to 9 months ago

I do experience this behaviour on my own pc as well as my office pc so I guess I can reproduce the issue

DoGauss avatar May 31 '25 05:05 DoGauss

A-ha!

Image

So, PowerShell is minimizing its "console window," and we don't take kindly to that. We probably should.

In the meantime, if you remove -windowstyle minimized from your pwsh command line and instead set it in task scheduler itself:

Image

does that work?

... if not, how about -windowstyle hidden?

DHowett avatar Jun 04 '25 19:06 DHowett

My observations:

  • The task option "hidden" doesn't work
  • "-windowstyle hidden" does work if I supply it as argument to pwsh like wt -w _quake pwsh -nologo -windowstyle hidden -NoExit

That doesn't allow me to use my wt profiles - neither implicitly the default profile nor explicitly any other wt -w _quake -p "my profile" -windowstyle hidden That expectetly throws an error as "-windowstyle hidden" is a parameter to pwsh and not to wt:

Image

My ultimate goal is to start my (default) profile in quake mode at startup and have that initially hidden so I have quick assess to it with the hotkeys I bound

DoGauss avatar Jun 05 '25 04:06 DoGauss

Perhaps this?

wt -w _quake -p "my profile" --appendCommandLine -- -WindowStyle Hidden

It's a mouthful, but it works over here.

DHowett avatar Jun 05 '25 16:06 DHowett

Not much luck over here. If I do it this way I do get a running terminal - but it is CMD not pwsh. It looks like an instance of CMD was dynamically generated from my default settings, and windowsstyle got completely ignored. My actual profile I tried to invoke should have been a pwsh based profile. My literal invocation is wt -w _quake -p "PS7-Stable ITCO" --appendCommandLine -- -WindowStyle Hidden There's no difference betwenn running from WIN+R and running from task scheduler

This profile is defined as { "backgroundImage": "%OneDriveConsumer%\\Bilder\\web\\rudi_outline.png", "commandline": "C:\\Program Files\\PowerShell\\7\\pwsh.exe", "cursorShape": "vintage", "guid": "{2aef55bd-f481-4f60-8b21-58c0b5cd857b}", "hidden": false, "icon": "%OneDriveConsumer%\\Bilder\\Icons\\256\\rudi_outline.png", "name": "PS7-stable ITCO" }

whereas my defaults are { "antialiasingMode": "aliased", "backgroundImage": "%OneDriveConsumer%\\Bilder\\web\\terminal-256.png", "backgroundImageAlignment": "bottomRight", "backgroundImageOpacity": 0.1, "backgroundImageStretchMode": "none", "closeOnExit": "automatic", "colorScheme": "Tango Dark", "cursorColor": "#FFFFFF", "cursorShape": "bar", "experimental.retroTerminalEffect": false, "font": { "face": "FiraCode Nerd Font", "size": 10 }, "historySize": 20000, "opacity": 75, "padding": "0, 0, 0, 0", "snapOnInput": true, "startingDirectory": "C:\\repos", "useAcrylic": true }

Am I missing something? I'll be AKF for a few days. I'll get back in touch afterwards.

DoGauss avatar Jun 06 '25 11:06 DoGauss

Perhaps this?

wt -w _quake -p "my profile" --appendCommandLine -- -WindowStyle Hidden

It's a mouthful, but it works over here.

Can confirm this works on my machine.

I used the stock PowerShell 7.5.1 profile so my command was wt -w _quake -p "PowerShell" --appendCommandLine -- -WindowStyle Hidden.

arqalite avatar Jun 06 '25 21:06 arqalite

The one that works for me:

To start powershell: wt.exe --window "_quake" powershell -window hidden

To start cmd (opens it kinda in powershell tab): wt.exe --window "_quake" powershell -window hidden cmd

This way it doesn't spawn minimized window bug. Also works through autostart shortcut.

Vallek avatar Jun 07 '25 09:06 Vallek

Antonio's comment about using a stock profile gave me something to think about. The stock profile is basically just this: "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": true, "name": "PowerShell", "source": "Windows.Terminal.PowershellCore" As Antonio found this does work as I want it to.

It still should work when using the commandline parameter but doesn't I'm somewhat dependent on that as I have almost 20 profiles tailored to my various use cases. The source parameter and the default GUIDs are insuficient for most of my profiles

DoGauss avatar Jun 19 '25 13:06 DoGauss

So, this is one place where the settings UI makes it easier to handle. You don't want to replace the source (that's how Terminal knows that this profile was auto-detected, and where it came from!) but rather to get the existing commandline and append to it.

Image

If you open up the settings page, you can see exactly what it's set to and update it there.

DHowett avatar Jun 19 '25 14:06 DHowett

I was about to write a lengthy reply and report what I experienced in the last two hours of testing when I apparently stumbled over the solution: The value following wt -w _quake -p is case sensitive.

For whatever reason my profile was named PS7-stable ITCO whereas I used PS7-Stable ITCO as value to the profile parameter when invoking wt Don't know if this is a historic discrepancy, a mishap, a typo, ... on my part but the correctly cased s/S did the trick. Retrospectively the strings are extractly show that way in my last post on June 6th.

Can anyone independently verify this?

Regarding the case sensitivity nothing is mentioned here https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments @DHowett If my finging is correct, can you update the documentation on that site to spare everybody else this potential trap?

DoGauss avatar Jun 19 '25 16:06 DoGauss

Argh! I even tested that!

I just realized that my test failed to reproduce the failure because it chose my default profile when it couldn't find all-lowercase powershell, and PowerShell when it found PowerShell.

It just so happens that my default profile is ... PowerShell. 🤦🏻

DHowett avatar Jun 19 '25 17:06 DHowett

@DHowett with the correct and case-sensitive spelling of the profile I'm quite happy how it now works as I want it to. One question came up though: This https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows doesn't have all the command line arguments there are. At least this is missing: --appendCommandLine --

Is there more documentation I can read?

DoGauss avatar Jul 02 '25 06:07 DoGauss