If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: windows form .call console and give commands

If I understand the problem, you are trying to set the input and read the output of a console app? If so, then AllocConsole isn't going to help.

AllocConsole only helps if you want to open a console window to your process, and if you are trying to do that there is an even easier way to create a console window for your forms app - that is to simply set the application type of your forms app to 'console app'. A console window will then open along side the forms window.

But as I said, that isn't going to help if the console window you are interested in is in another process. If you are trying to send and receive text in another console app process, you are going to have to open that process with the Process class and redirect stdin and stdout as I mentioned earlier.

There is a lot of help available to do this - just search bing or google for "redirect stdinput process C#".

If I understand the problem, you are trying to set the input and read the output of a console app? If so, then AllocConsole isn't going to help.

AllocConsole only helps if you want to open a console window to your process, and if you are trying to do that there is an even easier way to create a console window for your forms app - that is to simply set the application type of your forms app to 'console app'. A console window will then open along side the forms window.

But as I said, that isn't going to help if the console window you are interested in is in another process. If you are trying to send and receive text in another console app process, you are going to have to open that process with the Process class and redirect stdin and stdout as I mentioned earlier.

There is a lot of help available to do this - just search bing or google for "redirect stdinput process C#".

I cant find solution for thatIts a windows forum
on button click open console and readline to assign the value to $tring or int array
and later show in mbox

in console app.itss so easy
but on windows form applcation how to call console? and assign value to $tring or int(*array?)

1. "It's a Windows Form (application)"
2. "On a button click, I want to open console and readline to assign the value to a string or integer array and later show in a MessageBox."
3. "In a console app, it is so easy, but on windows form applcation how do I call the console?"

He didn't mention anything about a console based program, he only mentioned calling the console. If he wanted user input to the console, then he would have to create a program to do this and just act as a variable initializer, which I don't think is what he's doing...

I could be wrong, but he never mentioned a console program at all. He only asked how to call the console. I would wonder why he doesn't just use a TextBox though? Using the console just for user input to a string variable seems unethical to me.

Re: windows form .call console and give commands

Originally Posted by AceInfinity

He didn't mention anything about a console based program, he only mentioned calling the console. If he wanted user input to the console, then he would have to create a program to do this and just act as a variable initializer, which I don't think is what he's doing...

I could be wrong, but he never mentioned a console program at all. He only asked how to call the console. I would wonder why he doesn't just use a TextBox though? Using the console just for user input to a string variable seems unethical to me.

I just went by exactly what he said he wanted to do, and no more.

Yeah, sometimes it's tough trying to figure out what an OP is trying to do.

Generally, many [beginner] folks confuse a console app with the console window that Windows displays the app in. Because of this, they think the way to input data into a console app is to somehow enter it into the console window. Likewise, to get the output of a console app, they usually think they need to somehow scrape the console window.

While this can be done, it generally isn't the best approach in terms of robustness, so the more common approach is to use the redirect method I've mentioned.

Re: windows form .call console and give commands

Originally Posted by Arjay

Yeah, sometimes it's tough trying to figure out what an OP is trying to do.

Generally, many [beginner] folks confuse a console app with the console window that Windows displays the app in. Because of this, they think the way to input data into a console app is to somehow enter it into the console window. Likewise, to get the output of a console app, they usually think they need to somehow scrape the console window.

While this can be done, it generally isn't the best approach in terms of robustness, so the more common approach is to use the redirect method I've mentioned.

Perhaps the OP will post back to clarify?

You're not wrong though, I'm not saying that. I'll wait and see until OP can clarify what he's willing to do before going further in a specific direction. It's like a forest, you don't start going in any one direction unless you know where you are, and where you want to be headed, otherwise you're more likely to get lost.

Re: windows form .call console and give commands

Originally Posted by Arjay

Say Ace, were you able to make the MVP Summit in Bellevue last week?

Nope... Sadly. I did want to go, but no real way of transportation for me, and I am of the slightly younger audience among MVP's. It would have been a good opportunity to meet usasma and jcgriff, who I know fairly well since I was initially awarded in 2012.