问题
I have an app that needs a virtual keyboard. But, when I click some of my TextBox
es, they don't make the virtual keyboard appear. I have tried using this:
System.Diagnostics.Process.Start("osk.exe");
But this opens another keyboard, one that does not close after the TextBox
has no focus. How to force win10 to open the virtual tablet keyboard?
To make myself clear:
This is running on a win10 touch screen PC. When I have the tablet mode enabled the virtual keyboard shows up on some TextBox
es and does not on others. Hence why I want to force the keyboard to show.
EDIT: I have since found a way to show the "virtual tablet keyboard", however I would like to do it using the InputPane class. Can someone provide me with a example code just to get me started?
Code to open it without using the InputPane class:
System.Diagnostics.Process.Start("TabTip.exe");
回答1:
One thing. InputPane, you cannot use in WinForms, InputPane is a element of UWP.
I ran this code... And Works!
string progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
string keyboardPath = Path.Combine(progFiles, "TabTip.exe");
Process.Start(keyboardPath);
But I had to add a key (MANUALLY) value on my regedit on HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip
inside the key is a folder named 1.7 (this would change in the future by Microsoft) and add a 32 bit DWORD value named EnableDesktopModeAutoInvoke
with value 1
. This means TRUE. It should look like this:
You can add the key programatically I think you need Admin privilegies. I tried add the key programatically but does not work, It double the entry without any effect (BE CAREFUL);
ADVICES:
Consider, do a process stopper for each process you create. I suposse that you will use this when textbox (ar any input method) request focus. be sure stop the process when component loses his focus.
hope this help.
来源:https://stackoverflow.com/questions/37249607/how-to-force-win10-to-open-virtual-tablet-keyboard