-1

I've an application same as command line application. I type command, it send command to server and display result on screen. My application is an executable application on windows and has two feature that help me to easy work: record script and play script. Now, I want to send command to running application and raise play script button to run sent command on it. Is there any way to solve this problem in c# language?

1 Answers1

0

Uh-oh. I hope I understood you correctly. I assume you have a third-party application that interacts with some server and is operated by two distinct commands, play and record. You want to write a new application that would invoke these commands somehow, and the problem is this invocation.

You can do it in C#, but the way you do it depends on the way you operate the program. I will show you some cases:

  • The program is a command line tool. Input is sent via command line parameters when the program is run. Output is gathered via redirections of the standard output of the program. Look at System.Diagnostics.Process.Start and its parameters, namely ProcessStartInfo which contains parameters and input/output redirection options.
  • The program is a console tool that is not operated via command line parameters. Use the same as above, but feed input via input redirection.
  • The program is a GUI program with no ability to get input in text form. This is most likely the case. Here you will have to either find a specific way to operate the program such as with an advanced technique called hooking. Or you can send commands as if a user is issuing them. Look at System.Windows.Forms.SendKeys method. It might help. How to get a result here is a big question. You can either parse the screen or monitor some state of a program or something else. No ready solution for everyone here.
Aneri
  • 1,342
  • 8
  • 21
  • Thank for your response Aneri, I'm succeed to start an exe application in c# and send key or character to it same as Calculator.exe and notepad.exe. But I've an application which I can not send any key or this doesn't have any behavior. How I can know about my application for this capability for transact with c# application? – Mohammad reza Beizavi Feb 01 '15 at 06:04