How to embed cmd input box in another program? #1692

Closed
opened 2026-01-30 22:33:53 +00:00 by claunia · 5 comments
Owner

Originally created by @kernelbin on GitHub (Jun 15, 2019).

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 !!!

Originally created by @kernelbin on GitHub (Jun 15, 2019). 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 !!!
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 18, 2019):

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.

@DHowett-MSFT commented on GitHub (Jun 18, 2019): For early 2019, you'll want to look at the pseudoconsole API -- a good starting point is here on MSDN, [Creating a Pseudoconsole Session](https://docs.microsoft.com/en-us/windows/console/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.
Author
Owner

@kernelbin commented on GitHub (Jun 18, 2019):

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 ?

@kernelbin commented on GitHub (Jun 18, 2019): > For early 2019, you'll want to look at the pseudoconsole API -- a good starting point is here on MSDN, [Creating a Pseudoconsole Session](https://docs.microsoft.com/en-us/windows/console/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 ?
Author
Owner

@zadjii-msft commented on GitHub (Jun 18, 2019):

@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.

@zadjii-msft commented on GitHub (Jun 18, 2019): @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](https://docs.microsoft.com/en-us/windows/console/console-functions). 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.
Author
Owner

@kernelbin commented on GitHub (Jun 18, 2019):

@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.

@kernelbin commented on GitHub (Jun 18, 2019): > @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](https://docs.microsoft.com/en-us/windows/console/console-functions). 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.
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 18, 2019):

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

@DHowett-MSFT commented on GitHub (Jun 18, 2019): I'm gonna close this one as it's been answered. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1692