1
votes

I have an small application in WPF with two textBox. One of them must show the Touch Keyboard when it gets focus. It is works correclty using the next code:

Process theTouchKeyboardProcess = null;
...

private void textBoxA_GotFocus(object sender, RoutedEventArgs e)
{
   theTouchKeyboardProcess = Process.Start(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe");
}

The problem is that I want to hide the touch keyboard when the another one textBox gets focus. I have tried to do this:

private void textBoxA_LostFocus(object sender, RoutedEventArgs e)
{
   try
   {
      theTouchKeyboardProcess.Kill();
   }
   catch (Exception ex)
   {
      Console.WriteLine(ex.StackTrace);
   }         
}

But It launches an exception.

The question is, What is the best way to do this correcty?

Thanks.

1
What exception is thrown?opewix
stackoverflow.com/a/19040902 check this it is working fineMohsin Afzal

1 Answers

1
votes

I don't know what is the best way, but I used the following code in my project, it just worked.

Process[] processes = Process.GetProcessesByName("TabTip");
foreach (Process process in processes)
{
    process.Kill();
}