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
VulpesPosted Aug 14, 2011, 4:45 AM
Amit RanjanPosted Aug 14, 2011, 1:11 AM
Sam HobbsPosted Aug 13, 2011, 8:28 PM
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.
VulpesPosted Aug 13, 2011, 2:56 PM
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}");
}