473,508 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send keys from .NET APP to an old APP

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
5 1803
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
10185
by: Etienne Charland | last post by:
Hi, there is an application running on a remote desktop (under Citrix ICA, but the same problem applies for RDC or PC Anywhere). Now, I want to send keys to the remote application from a local app....
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.