Hello members
I am working on a program in which i called a program exe file but the program which i called, using system.diagnostic.start ,givse output
when "alt+tab" is pressed is pressed
followed by "tab"
and finally "Enter"
i dont want any user input in middle i want automatically output from the program plz guide how i can press space bar programatically.
I used the following codes to do this
if (e.Result.Text == "Time") // TIME has been added to sppech grammmer first
{
Process.Start("C://Program Files//amitbot.exe");
Thread.Sleep(200);
SendKeys.Send("%{TAB}");
Thread.Sleep(200);
SendKeys.Send("{TAB}");
Thread.Sleep(200);
SendKeys.Send("{ENTER}");
}
While this code successfully executes the ALT+TAB command, But the following commands are not executed. Instead message is displayed that programme can't be changed while debugging.
plz give a detailed answer i am struck very badly.
Loading

VulpesRank #55 · 29.2K reputationPosted Aug 13, 2011, 10:56 AM EDT
If the process has a message loop (i.e. it's a Windows Forms or WPF application), I'd try calling Process.WaitForInputIdle before sending each key to make sure it's in a position to respond:
if (e.Result.Text == "Time") // TIME has been added to sppech grammmer first
{
Process p = Process.Start("C://Program Files//amitbot.exe");
Thread.Sleep(200);
p.WaitForInputIdle();
SendKeys.Send("%{TAB}");
Thread.Sleep(200);
p.WaitForInputIdle();
SendKeys.Send("{TAB}");
Thread.Sleep(200);
p.WaitForInputIdle();
SendKeys.Send("{ENTER}");
}
Sam HobbsRank #108 · 20.5K reputationPosted Aug 13, 2011, 4:28 PM EDT
Also, note that many developers use SendKeys and many developers do not. SendKeys sounds easy and obvious but there is probably an easier way to do it; you just need to know a little bit more about how Windows works.
Amit Ranjan6 reputationPosted Aug 13, 2011, 9:11 PM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 14, 2011, 12:45 AM EDT