简体   繁体   English

WPF经典Windows应用在Windows 10 Pro上作为自定义外壳的屏幕键盘问题

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

I've created a WPF app which runs as custom shell on Windows 10 - Pro v. 1607 ASUS TP 201 tablets. 我创建了一个WPF应用程序,该程序在Windows 10-Pro v。1607 ASUS TP 201平板电脑上作为自定义外壳程序运行。

Classic windows apps as custom shells can't be defined in Windows 10 - Pro. 在Windows 10-Pro中无法将经典Windows应用程序作为自定义外壳程序进行定义。 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. 应用运行良好,但在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. 即使不是将应用程序作为自定义外壳运行,也可以将其作为Windows Shell之后的应用运行良好。 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: 我尝试了在Tocuh事件之后启动键盘可执行文件的方法:

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. 1)要启动osk.exe,由于osk.exe是在64位系统上运行的32位应用程序,因此需要从WinSxS组件存储中释放可执行文件。 The caveat is that folders in WinSxS are named with a long string that includes a hash. 需要注意的是,WinSxS中的文件夹用包含哈希的长字符串命名。 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. 2)要启动tabtip.exe,我需要以管理员权限启动该过程,该应用程序会提示一个对话框,要求输入管理员密钥,由于平板电脑用户没有管理员权限,因此无法执行。

3) Installed a licensed custom keyboard, tabtipondemand, and same as 2, requires admin key. 3)安装了许可的自定义键盘tabtipondemand,与2相同,需要管理员密钥。

I wonder why in order to launch tabtip.exe, administrator level is required. 我想知道为什么要启动tabtip.exe,需要管理员级别。

 Process.Verb = "runas";

If not launched with admin, then the virtual keyboard fails, only and empty dialog box appears. 如果未使用admin启动,则虚拟键盘将失败,并且仅会出现一个空对话框。

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. 1)如何在作为自定义外壳程序运行的经典Windows WPF应用程序中启动tabtip.exe,没有管理员的Windows 10本机屏幕键盘。

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. 2)如何定义通用或动态路径以从Windows组件存储WinSxS启动osk.exe,而不是为每台计算机自定义每个路径。

3) Can I compile in my app any library, dll, to enable the native behavior of tabtip.exe when apps run over windows shell? 3)我可以在我的应用程序中编译任何库dll,以在应用程序通过Windows Shell运行时启用tabtip.exe的本机行为吗?

Let me be clear on this: 让我清楚一点:

1) I'm running a windows classic app as custom shell, not an UWA. 1)我正在运行Windows经典应用程序作为自定义外壳程序,而不是UWA。

2) The machines on which the app should run as custom shell, are Windows 10 - Pro v 1607, touchscreen, Asus tp201. 2)该应用程序应作为自定义外壳程序运行的计算机是Windows 10-Pro v 1607,触摸屏,华硕tp201。

3) The custom shell is not running from any app store or kiosk mode. 3)自定义外壳程序不在任何应用商店或信息亭模式下运行。 Due to licensing complexities, a classic windows app cannot run as custom shell on Windows 10 pro. 由于许可的复杂性,传统的Windows应用程序无法在Windows 10专业版上作为自定义外壳运行。

4) The custom shell is configured by modifying the register, which works fine, there are no issues on that. 4)通过修改寄存器来配置自定义外壳,效果很好,没有任何问题。

5) At the moment is not possible to migrate our native WPF app to UWA. 5)目前无法将本机WPF应用迁移到UWA。 There is som PITA on customizing shells with UWA. 有关于使用UWA定制外壳的som PITA。

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. 好吧,我设法找到了一个完美的解决方案来解决在Windows 10应用程序中作为自定义外壳运行的Windows桌面应用程序中显示虚拟键盘的问题。

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 . 请记住,通过作为自定义外壳运行,Windows 10本机虚拟键盘不会显示,因此我使用了Alexei SherbakovGithub上共享的便捷库osklib It's also available as a package in Nuget PM, ready to use in VS. 它也作为Nuget PM中的软件包提供,可以在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: 添加Osklib作为对项目的引用,并使用Gotfocus事件触发任何形式的事件,该事件属于System.Windows.Forms命名空间:

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

Then create the TriggerKeyboard event invoking Osklib class: 然后创建调用Osklib类的TriggerKeyboard事件:

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. 感谢阿列克谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM