本文介绍了WPF 经典 Windows 应用程序作为 Windows 10 专业版上的自定义外壳的屏幕键盘问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 WPF 应用,它在 Windows 10 - Pro v. 1607 ASUS TP 201 平板电脑上作为自定义 shell 运行.

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

无法在 Windows 10 - 专业版中定义作为自定义外壳的经典 Windows 应用程序.所以我修改了注册表,以便为自定义用户分配自定义 shell.

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.

应用程序运行良好,除了在 TextBox 上触发触摸事件后不会弹出虚拟键盘.在我的开发机器上测试时,它工作正常,按预期提示键盘.即使不是作为自定义外壳运行应用程序,作为 Windows 外壳之后的应用程序,也能正常工作.仅当应用作为自定义 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.

我尝试过在 Tocuh 事件后启动键盘可执行文件的方法:

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

本次活动由:

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

然而:

1) 要启动 osk.exe,需要从 WinSxS 组件商店启动可执行文件,因为 osk.exe 是在 64 位上运行的 32 位应用程序.需要注意的是,WinSxS 中的文件夹使用包含哈希的长字符串命名.由于每个平板电脑都有一个自定义名称,因此我无法为每个平板电脑指定启动路径.

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) 要启动 tabtip.exe,我需要以管理员权限启动该进程,这样做时,应用程序会提示需要管理员密钥的对话框,但由于平板电脑用户不这样做,因此无法完成拥有管理员权限.

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) 安装了授权的自定义键盘,tabtipondemand,与 2 相同,需要管理员密钥.

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

我想知道为什么要启动tabtip.exe,需要管理员级别.

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

 Process.Verb = "runas";

如果不是用 admin 启动,则虚拟键盘失败,只出现空对话框.

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

所以我的问题是:

1) 如何在作为自定义 shell 运行的经典 Windows WPF 应用程序中启动 tabtip.exe,Windows 10 本机屏幕键盘,无需管理员.

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

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) 当应用在 Windows shell 上运行时,我可以在我的应用中编译任何库 dll 以启用 tabtip.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?

让我澄清一下:

1) 我将 Windows 经典应用作为自定义外壳运行,而不是 UWA.

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

2) 应用程序应作为自定义 shell 在其上运行的机器是 Windows 10 - Pro v 1607、触摸屏、Asus tp201.

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

3) 自定义 shell 未从任何应用商店或自助服务终端模式运行.由于许可的复杂性,经典的 Windows 应用无法在 Windows 10 专业版上作为自定义外壳运行.

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) 自定义shell是通过修改寄存器配置的,效果很好,没有问题.

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

5) 目前无法将我们的原生 WPF 应用程序迁移到西澳大学.有一些关于使用 UWA 自定义 shell 的 PITA.

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

推荐答案

好吧,我设法找到了一个完美的解决方案,以解决在 Windows 10 上作为自定义外壳运行的 Windows 桌面应用程序中显示虚拟键盘的问题.

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.

考虑到作为自定义 shell 运行时,Windows 10 本机虚拟键盘不会显示,我使用了 Alexei SherbakovGithub 称为 osklib.它也可以作为 Nuget PM 中的一个包提供,随时可以在 VS 中使用.

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.

添加 Osklib 作为对您项目的引用,并从属于 System.Windows.Forms 命名空间的任何具有 Gotfocus 事件的表单触发事件:

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" />

然后创建调用 Osklib 类的 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.

这篇关于WPF 经典 Windows 应用程序作为 Windows 10 专业版上的自定义外壳的屏幕键盘问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:38