Posted on 2003-10-26
Last Modified: 2007-12-19
   Iam having a small problem in using the System.Windows.Forms.SendKeys API to send input to an active appication. I have an exe file for adding two numbers. I have to give input to that and get the result. My code ( which i have given below) works sometime and does not work someother time. It gives and unhandled exception error. can anyone tell me why?
   Dim myProcess As Process = New Process()
   myProcess.StartInfo.FileName = "Addition.exe"
   myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
   myProcess.EnableRaisingEvents = True
         If myProcess.Responding Then
        End If


Question by:sendhil_an
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

brother7 earned 50 total points
ID: 9624332
Lemme see if I understand this correctly...
1- The result is received back after the 2nd {ENTER}
2- The 3rd {ENTER}'s purpose is to try to end the process normally, ie in response to "Press any key to continue"

I would try the following:
   Add myProcess.CloseMainWindow() as the last statement of the If block, before the Else block.

Do you know the type of Exception that's occurring?
Add a Catch block, such as:
   Catch exceptionParameter as Exception
      MessageBox.Show(exceptionParameter.Message, "Caught Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
   End Try

Hope that helps some.
LVL 96

Expert Comment

by:Bob Learned
ID: 10224382
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: brother7 {http:#9624332}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adjust the codes 3 65
Set arraylist as datatable 2 30
Convert a string to date 4 40
input validations, TryUpdateModel and model binding  in mvc 5 25
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question