Terminal: How to embed cmd input box in another program?

Created on 15 Jun 2019  路  5Comments  路  Source: microsoft/terminal

I want to use cmd inputbox in my own program, and I've tried many ways but none of them successed ( Include Create The conhost window as a child window, SetParent Function, and so on )
The might be many people want to use this powerful inputbox as well, And I wonder what should I do to make that.
Thanks !!!

Area-TerminalControl Issue-Question Product-Meta Resolution-Answered

Most helpful comment

For early 2019, you'll want to look at the pseudoconsole API -- a good starting point is here on MSDN, Creating a Pseudoconsole Session.

We're planning to make the TerminalControl and DirectWrite renderer/terminal buffer/VT parser components of Windows Terminal reusable and hostable for other applications. There's some work there going on in #1274 and #1263.

All 5 comments

For early 2019, you'll want to look at the pseudoconsole API -- a good starting point is here on MSDN, Creating a Pseudoconsole Session.

We're planning to make the TerminalControl and DirectWrite renderer/terminal buffer/VT parser components of Windows Terminal reusable and hostable for other applications. There's some work there going on in #1274 and #1263.

For early 2019, you'll want to look at the pseudoconsole API -- a good starting point is here on MSDN, Creating a Pseudoconsole Session.

We're planning to make the TerminalControl and DirectWrite renderer/terminal buffer/VT parser components of Windows Terminal reusable and hostable for other applications. There's some work there going on in #1274 and #1263.

Thanks!

Is there any difference between creating a psedoconsole session and creating a new cmd exe process with hStdInput/hStdOutput set in STARTUPINFO ?

@yh-git Yes there is. When a commandline application is started with redirected input and output, it can't make use of the large majority of the Console API. For example, a user wouldn't be able to use the arrow keys to navigate the input line if cmd.exe was just created redirected. The Pseudoconosle API, however, does attach the commandline application to a full console, so the application can use the full console API. The pseudoconsole will then do the hard work of translating those API calls into a stream of characters, with VT sequences embedded in the output. You'll need to be able to handle a few types of VT sequences to be able to properly display pseudoconsole output.

@yh-git Yes there is. When a commandline application is started with redirected input and output, it can't make use of the large majority of the Console API. For example, a user wouldn't be able to use the arrow keys to navigate the input line if cmd.exe was just created redirected. The Pseudoconosle API, however, does attach the commandline application to a full console, so the application can use the full console API. The pseudoconsole will then do the hard work of translating those API calls into a stream of characters, with VT sequences embedded in the output. You'll need to be able to handle a few types of VT sequences to be able to properly display pseudoconsole output.

Thanks alot! pseudoconsole is just what i'm looking for, sounds attractive. I will try it.

I'm gonna close this one as it's been answered. Thanks!

Was this page helpful?
0 / 5 - 0 ratings