473,770 Members | 1,661 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.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
Nov 16 '05 #1
5 1815
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

Nov 16 '05 #2
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


Nov 16 '05 #3
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


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

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

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
10225
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. I tried sending keys in VB with SendKeys, as well as using keybd_event API, but I'm not able to send any keys. It works very well for any local applications, but I can't pass the keys remotely. Is there any way to do it? Thanks! Etienne
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2822
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.