OnScreen keyboard issue with WPF Classic Windows App as Custom Shell on Windows 10 Pro

点点圈 提交于 2019-12-24 10:44:17

问题


I've created a WPF app which runs as custom shell on Windows 10 - Pro v. 1607 ASUS TP 201 tablets.

Classic windows apps as custom shells can't be defined in Windows 10 - Pro. So I modified the registry in order to assign for a custom user, a custom shell.

App runs well except for the fact that virtual keyboard don't popup once a touch event is triggered on TextBoxes. Whe testing on my development machine it works, fine, prompts the keyboard as expected. Even running the app not as custom shell, as an app after windows shell, works fine. The on screen keyboard fails only when the app runs as custom shell.

I've tried the approach of launching a keyboard executable after a Tocuh event:

private void launchKeyboard(object sender, RoutedEventArgs e) 
{
   Process.Start(@"C:\[Path]\osk.exe");
}

This event is started by:

<Textbox x:Name="textbox" GotFocus="launchKeyboard" ... />

However:

1) To launch osk.exe, it's required to lauch the executable from WinSxS component Store, due to the fact that osk.exe is a 32bit app running on 64bit. The caveat is that folders in WinSxS are named with a long string that includes a hash. So I can't specify the launching path for each tablet due to the fact that each one has a custom name.

2) To launch tabtip.exe, I need to start the process with administrator rights, doing so, the app prompts a dialog requiring admin keys, which can't be done, due to the fact that tablet users don't have admin privileges.

3) Installed a licensed custom keyboard, tabtipondemand, and same as 2, requires admin key.

I wonder why in order to launch tabtip.exe, administrator level is required.

 Process.Verb = "runas";

If not launched with admin, then the virtual keyboard fails, only and empty dialog box appears.

So my questions are:

1) How can I launch tabtip.exe, windows 10 native onscreen keyboard without administrator, in a classic windows WPF app running as custom shell.

2) How can I define a universal or dynamic path to launch osk.exe from Windows component store, WinSxS, instead of customizing each path for each machine.

3) Can I compile in my app any library, dll, to enable the native behavior of tabtip.exe when apps run over windows shell?

Let me be clear on this:

1) I'm running a windows classic app as custom shell, not an UWA.

2) The machines on which the app should run as custom shell, are Windows 10 - Pro v 1607, touchscreen, Asus tp201.

3) The custom shell is not running from any app store or kiosk mode. Due to licensing complexities, a classic windows app cannot run as custom shell on Windows 10 pro.

4) The custom shell is configured by modifying the register, which works fine, there are no issues on that.

5) At the moment is not possible to migrate our native WPF app to UWA. There is som PITA on customizing shells with UWA.


回答1:


Well I managed to find a perfect solution for the issue of displayng a virtual keyboard in a windows desktop app that runs as custom shell on Windows 10.

Having in mind that by running as custom shell the Windows 10 native virtual keyboard does not display, I used a handy library shared by Alexei Sherbakov on Github called osklib. It's also available as a package in Nuget PM, ready to use in VS.

Add Osklib as a reference to your project, and trigger an event from any form with the Gotfocus event, which belong to the System.Windows.Forms namespace:

<TextBox ... Gotfocus="TriggerKeyboard" />

Then create the TriggerKeyboard event invoking Osklib class:

private void TriggerKeyboard(object sender, EventArgs e) {
     try {
        Osklib.OnScreenKeyboard.Show();
     } 
    catch(Exception ex) {
       MessageBox.Show(ex.Message);
    }
 }

That's all quick and easy and failproof. Thanks to Alexei.



来源:https://stackoverflow.com/questions/45227217/onscreen-keyboard-issue-with-wpf-classic-windows-app-as-custom-shell-on-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!