How to programmatically detect/force console host? #19223

Closed
opened 2026-01-31 06:37:19 +00:00 by claunia · 2 comments
Owner

Originally created by @dts350z on GitHub (Jan 16, 2023).

So I have a console application that uses SetConsoleWindowInfo, etc. which does nothing in windows terminal.

Windows Terminal is now the default in windows 11, and while users can set ALL console hosts to be windows terminals or the old console, I don't see anyway for console applications to determine which is selected or to force the right choice for the API in use.

"Let Windows Decide" doesn't seem to do anything except make everything windows terminals.

I also don't see a 1:1 equivalency between the old API and Virtual Terminal Escape sequences. E.g. one can set the width, but not the height?

Please advise.

Originally created by @dts350z on GitHub (Jan 16, 2023). So I have a console application that uses SetConsoleWindowInfo, etc. which does nothing in windows terminal. Windows Terminal is now the default in windows 11, and while users can set ALL console hosts to be windows terminals or the old console, I don't see anyway for console applications to determine which is selected or **to force the right choice for the API in use**. "Let Windows Decide" doesn't seem to do anything except make everything windows terminals. I also don't see a 1:1 equivalency between the old API and Virtual Terminal Escape sequences. E.g. one can set the width, but not the height? Please advise.
Author
Owner

@zadjii-msft commented on GitHub (Jan 16, 2023):

What are you trying to achieve with SetConsoleWindowInfo/? I'd personally rather try to find the right way to replicate that functionality in the Terminal, rather than provide an escape hatch. If we really can't find a sensible way of replicating that in the Terminal, well, we can talk about escape hatches then 😉

@zadjii-msft commented on GitHub (Jan 16, 2023): What are you trying to achieve with `SetConsoleWindowInfo`/? I'd personally rather try to find the right way to replicate that functionality in the Terminal, rather than provide an escape hatch. If we really can't find a sensible way of replicating that in the Terminal, well, we can talk about escape hatches then 😉
Author
Owner

@dts350z commented on GitHub (Jan 16, 2023):

I use Get/SetConsoleScreenBufferSize to set the buffer

I use SetConsoleWindowInfo to set the window size to {0, 0, 150 , 20}

I use CONSOLE_SCREEN_BUFFER_INFO with GetStdHandle(STD_OUTPUT_HANDLE to get the X and Y current cursor position

I use SetConsoleCursorPosition to set the cursor position

I use SetConsoleTextAttribute to set font colors (some works in windows terminal, some does not. Some font colors not visible.)

What I get with Console Host:
image

What I get with Windows Terminal:
image

@dts350z commented on GitHub (Jan 16, 2023): I use Get/SetConsoleScreenBufferSize to set the buffer I use SetConsoleWindowInfo to set the window size to {0, 0, 150 , 20} I use CONSOLE_SCREEN_BUFFER_INFO with GetStdHandle(STD_OUTPUT_HANDLE to get the X and Y current cursor position I use SetConsoleCursorPosition to set the cursor position I use SetConsoleTextAttribute to set font colors (some works in windows terminal, some does not. Some font colors not visible.) What I get with Console Host: ![image](https://user-images.githubusercontent.com/5871786/212746767-2c55f92f-8cca-4b0b-8c7a-cea314230543.png) What I get with Windows Terminal: ![image](https://user-images.githubusercontent.com/5871786/212747245-935267d9-f957-447b-9b3a-39a054c0f559.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19223