I was trying to work up a working example,but ran into some roadblocks.. to
get a handle to that app, you can do this:
System.Diagnost ics.Process[] procProcesses =
System.Diagnost ics.Process.Get Processes();
foreach (System.Diagnos tics.Process procActiveProc in procProcesses)
{
if ( procActiveProc. MainWindowTitle == "whatever" )
{
// Do something - procActiveProc is a handle to that whole process now
}
}
But what I was thinking, was doing something like this:
procCmdWindow.S tartInfo.Redire ctStandardInput = true;
procCmdWindow.S tartInfo.UseShe llExecute = false;
procCmdWindow.S tandardInput.Wr ite("dir *.*\n\rdir");
But really, that is for when you create your own process.. I couldn't find
how to redirect stdin one the app is already running.. so, although I still
think this "can" be done somehow, I'm about out of ideas.
If nothing else, I've shown a way it *can't* be done!! :-) good luck!
"Go Perl" <pu********@yah oo.com> wrote in message
news:d3******** *************** ***@posting.goo gle.com...
How do you get the handle of the process. It is a seperate window.
"Drebin" <th*******@hotm ail.com> wrote in message
news:<LY******* **********@news svr15.news.prod igy.com>...
Agreed, if you get a handle to the process, you could so something like:
objProcess.Stan dardInput.Write ("this should show up in the console");
"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:uu******** ******@TK2MSFTN GP11.phx.gbl... SendKeys.SendWa it() works fine for a Windows app that I have to start
and then dismiss an initial dialog box -- even though my controlling app
is a console app.
I doubt it would work when *targeting* a console app however. Any
chance you could send the keystrokes to stdin instead?
--Bob
"Go Perl" <pu********@yah oo.com> wrote in message
news:d3******** *************** ***@posting.goo gle.com...
> Hello
>
> Here is an interesting question which I could not solve it.
>
> I have an old dos app for which source code is lost. I just have the
> exe file. So I have created a front-end for that. I linked the
> front-end to the back end exe file.
>
> Everything works fine except When I hit a button on the front end it
> brings up the dos app and I have to manually enter few key presses
> like F, F, N and ENTER or ESC for dos app to run an algorithm and
> output the results to a file.
>
> If only I could send these keystrokes from my c# app to this old exe
> file, I could automate this process and the user will not have to see
> the old exe file.
>
> I tried using sendkeys.sendwa it, but it is working on cmd.exe but not
> passing the keystrokes to this old app. Possibly, because it is
> sending just characters that are not recognized.
>
> If anyone has an idea to solve this please reply to this message . I
> would greatly appreciate the help and it will help me from re-writing
> thousands of lines of code.
>
>
> Regards,
> .NET Coder