Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have an issue with a .NET touchscreen application in Win7 (no PC keyboard connected). I am using part of the app to act as a terminal window to an external device. When the terminal window opens, I start the on screen keyboard by calling:-
C#
string progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
string onScreenKeyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
oskProcess = System.Diagnostics.Process.Start(onScreenKeyboardPath);

After I have finished with the terminal window, I wish to close the form by a single click on the X of the form, which will then automatically close the on screen keyboard. So I call:-

C#
Process[] oskProcessArray = Process.GetProcessesByName("TabTip");
foreach (Process onscreenProcess in oskProcessArray)
{
    onscreenProcess.Kill();
    onscreenProcess.Dispose();
}


This works perfectly, EXCEPT when the last key pressed was either a CTRL, ALT or SHIFT key. If this is the case, these remain "stuck" even after the keyboard is killed. If I restart the on screen keyboard, they are still highlighted.

If I click the red X of the keyboard firstly before closing my form, all is good. But I want/need to close both together by a single click from my code. SO, how do I clear any "stuck" keys when exiting the keyboard automatically, or is there a different way to do this?

Instead of killing the process, if I use :-
onscreenProcess.CloseMainWindow()
This will clear the "sticky" CTRL but does not exit the keyboard.
Posted
Updated 6-Oct-15 22:23pm
v2

1 solution

OK....
I found that if I wait a LONG time between calling the .CloseMainWindow() and the .Kill() it does work. I am just surprised that I have need to wait 1.5 seconds for the keyboard to close!
Not the most eloquent solution, but at least it works now:-
C#
Process[] oskProcessArray = Process.GetProcessesByName("TabTip");
foreach (Process onscreenProcess in oskProcessArray)
{
    Application.DoEvents();
    onscreenProcess.CloseMainWindow();
    Application.DoEvents();
    sleep(1500);
    onscreenProcess.Kill();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900