By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,506 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,506 IT Pros & Developers. It's quick & easy.

Send keys from .NET APP to an old APP

P: n/a
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.sendwait, 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
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
SendKeys.SendWait() 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********@yahoo.com> wrote in message
news:d3**************************@posting.google.c om...
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.sendwait, 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

Nov 16 '05 #2

P: n/a
Agreed, if you get a handle to the process, you could so something like:

objProcess.StandardInput.Write("this should show up in the console");

"Bob Grommes" <bo*@bobgrommes.com> wrote in message
news:uu**************@TK2MSFTNGP11.phx.gbl...
SendKeys.SendWait() 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********@yahoo.com> wrote in message
news:d3**************************@posting.google.c om...
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.sendwait, 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


Nov 16 '05 #3

P: n/a
How do you get the handle of the process. It is a seperate window.




"Drebin" <th*******@hotmail.com> wrote in message news:<LY*****************@newssvr15.news.prodigy.c om>...
Agreed, if you get a handle to the process, you could so something like:

objProcess.StandardInput.Write("this should show up in the console");

"Bob Grommes" <bo*@bobgrommes.com> wrote in message
news:uu**************@TK2MSFTNGP11.phx.gbl...
SendKeys.SendWait() 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********@yahoo.com> wrote in message
news:d3**************************@posting.google.c om...
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.sendwait, 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


Nov 16 '05 #4

P: n/a
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.Diagnostics.Process[] procProcesses =
System.Diagnostics.Process.GetProcesses();

foreach (System.Diagnostics.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.StartInfo.RedirectStandardInput = true;

procCmdWindow.StartInfo.UseShellExecute = false;

procCmdWindow.StandardInput.Write("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********@yahoo.com> wrote in message
news:d3**************************@posting.google.c om...
How do you get the handle of the process. It is a seperate window.




"Drebin" <th*******@hotmail.com> wrote in message

news:<LY*****************@newssvr15.news.prodigy.c om>...
Agreed, if you get a handle to the process, you could so something like:

objProcess.StandardInput.Write("this should show up in the console");

"Bob Grommes" <bo*@bobgrommes.com> wrote in message
news:uu**************@TK2MSFTNGP11.phx.gbl...
SendKeys.SendWait() 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********@yahoo.com> wrote in message
news:d3**************************@posting.google.c om...
> 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.sendwait, 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

Nov 16 '05 #5

P: n/a
The Process class has a static method for finding processes by name. See
what the EXE you're talking about is called in Task Manager's process list,
and have your code search for that name.

--Bob

"Go Perl" <pu********@yahoo.com> wrote in message
news:d3**************************@posting.google.c om...
How do you get the handle of the process. It is a seperate window.

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.