在Winform应用程序中关闭TabTip键盘时出现问题 [英] Problem closing TabTip keyboard in Winform application

查看:502
本文介绍了在Winform应用程序中关闭TabTip键盘时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我在Win7中遇到.NET触摸屏应用程序的问题(没有连接PC键盘)。我正在使用应用程序的一部分充当外部设备的终端窗口。当终端窗口打开时,我通过调用启动屏幕键盘: -

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:-

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);



完成终端窗口后,我想通过一个单独关闭表单单击表单的X,然后将自动关闭屏幕键盘。所以我打电话给: -




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:-

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





这完全有效,除非按下最后一个键是CTRL,ALT或SHIFT键。如果是这种情况,即使在键盘被杀之后,这些仍然卡住。如果我重新启动屏幕键盘,它们仍然会突出显示。



如果我在关闭表单之前先点击键盘的红色X,一切都很好。但是我希望/需要通过我的代码中的单击来关闭它们。那么,如何在自动退出键盘时清除任何卡住键,或者有不同的方法来执行此操作?



而不是杀死进程,如果我使用: -

onscreenProcess.CloseMainWindow()

这将清除粘性CTRL但不退出键盘。



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.

推荐答案

OK ....

我发现如果我在调用.CloseMainWindow()和.Kill()之间等待很长时间,它确实有效。我很惊讶我需要等待1.5秒让键盘关闭!

不是最有说服力的解决方案,但至少现在可以使用: -

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:-
Process[] oskProcessArray = Process.GetProcessesByName("TabTip");
foreach (Process onscreenProcess in oskProcessArray)
{
    Application.DoEvents();
    onscreenProcess.CloseMainWindow();
    Application.DoEvents();
    sleep(1500);
    onscreenProcess.Kill();
}


这篇关于在Winform应用程序中关闭TabTip键盘时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆