【问题标题】:Windows 8 Desktop App: Open tabtip.exe to secondary keyboard (for numeric textbox)Windows 8 桌面应用程序:打开 tabtip.exe 到辅助键盘(用于数字文本框)
【发布时间】:2013-03-16 19:34:56
【问题描述】:

我们正在开发一个在 Windows 7 平板电脑上运行的桌面 WPF 应用,并且正在添加一些带有 Windows 8 的 Surface Pro 设备。

我们立即注意到,当 TextBox 获得焦点时,小键盘图标不再显示。我们通过在所有 TextBox 的 MouseDown 事件上运行“tabtip.exe”来解决它。

虽然我们有一些数字文本框(订单中商品的数量),并且希望打开屏幕键盘以输入数字,但它默认使用 qwerty 键打开。

我一直在广泛搜索可以传递给 tabtip.exe 以更改其输入模式的任何命令行参数,但没有运气。对于 Metro 风格的应用来说,这似乎是一项微不足道的任务,但在桌面端却是不可能的。

我可以使用 tabtip.exe 的命令行参数来完成此操作吗?

【问题讨论】:

    标签: wpf windows-8 desktop-application on-screen-keyboard


    【解决方案1】:

    根据@tymes 提供的答案,这是一个快速控制台应用程序,它演示了如何打开键盘并更改各种设置(C#)。:

    using System;
    using System.Diagnostics;
    using Microsoft.Win32;
    
    namespace CSharpTesting
    {
        class Program
        {
            /// <summary>
            /// The different layout types on the virtual keyboard.
            /// </summary>
            public enum KeyboardLayoutMode
            {
                Default,
                ThumbLayout,
                Handwriting
            }
    
            /// <summary>
            /// The registry key which holds the keyboard settings.
            /// </summary>
            private static readonly RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\TabletTip\\1.7");
    
            static void Main(string[] args)
            {
                SetKeyboardDockedMode(true);
                SetKeyboardLayoutMode(KeyboardLayoutMode.ThumbLayout);
                ShowKeyboard(true);
            }
    
            /// <summary>
            /// Shows the onscreen keyboard.
            /// </summary>
            /// <param name="killExistingProcess">If true, kill any existing TabTip.exe process.</param>
            public static void ShowKeyboard(bool killExistingProcess)
            {
                if (killExistingProcess)
                {
                    // If the user presses the close button on the keyboard then TabTip.exe will still run in the background. If we have made registry
                    // changes to the keyboard settings, they don't take effect until the process is started again so killing this ensures the keyboard
                    // will open with our new settings.
                    foreach (var process in Process.GetProcessesByName("TabTip"))
                    {
                        process.Kill();
                    }
                }
    
                string onScreenKeyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
                Process.Start(onScreenKeyboardPath);
            }
    
            /// <summary>
            /// Sets if the keyboard is in docked or floating mode.
            /// </summary>
            /// <param name="isDocked">If true set to docked, if false set to floating.</param>
            private static void SetKeyboardDockedMode(bool isDocked)
            {
                registryKey.SetValue("EdgeTargetDockedState", Convert.ToInt32(isDocked), RegistryValueKind.DWord);
            }
    
            /// <summary>
            /// Changes the layout mode of the keyboard.
            /// </summary>
            /// <param name="mode">The layout mode to use.</param>
            private static void SetKeyboardLayoutMode(KeyboardLayoutMode mode)
            {
                switch (mode)
                {
                    case KeyboardLayoutMode.Handwriting:
                        registryKey.SetValue("KeyboardLayoutPreference", 0, RegistryValueKind.DWord);
                        registryKey.SetValue("LastUsedModalityWasHandwriting", 1, RegistryValueKind.DWord);
                        break;
                    case KeyboardLayoutMode.ThumbLayout:
                        registryKey.SetValue("KeyboardLayoutPreference", 1, RegistryValueKind.DWord);
                        registryKey.SetValue("LastUsedModalityWasHandwriting", 0, RegistryValueKind.DWord);
                        // 0 = small, 1 = medium, 2 = large
                        registryKey.SetValue("ThumbKeyboardSizePreference", 2, RegistryValueKind.DWord);
                        break;
                    default:
                        registryKey.SetValue("KeyboardLayoutPreference", 0, RegistryValueKind.DWord);
                        registryKey.SetValue("LastUsedModalityWasHandwriting", 0, RegistryValueKind.DWord);
                        break;
                }
            }
        }
    }
    

    【讨论】:

    • 嗨,Barrie,你知道如何获取 TabTip 的所有注册键名吗?我正在尝试在键盘打开时获取启用大写的密钥...谢谢
    • 在显示屏幕键盘之前,如果大写锁定尚未打开,您可以模拟按下它。我认为这应该有效
    • 检查大写锁定然后启用的基本方法是大纲herehere
    【解决方案2】:

    HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7 (Windows 8) 更改 REG_DWORD KeyboardLayoutPreference 0 的值是常规布局 1 的值是中间有数字键盘的分体键盘

    REG_DWORD LastUsedModalityWasHandwriting 也必须是 0 或者如果是 1,当 tabtip 再次启动时,它将打开笔手写区域。

    【讨论】:

    • 太棒了!这个 DWORD 对我来说已经不存在于注册表中,所以我必须创建它。但它肯定有预期的效果。
    • 这适用于 Windows 8 机器,但在 Windows 10 中,TabTip.exe 在打开时似乎会重置所有注册表设置。
    • @jaredbaszler Windows 10 在存在手写笔时打开handwriting-view,否则打开打字视图。到目前为止,当没有手写笔时,我还没有发现任何以handwriting-view 开头的可能性。
    【解决方案3】:

    您可以通过 Tabtip 的注册表设置来控制输入模式。查找名称为 KeyboardLayoutPreference 的注册表项。

    【讨论】:

    • 我在 regedit 中搜索了该键,但没有收到任何结果。我在谷歌上也找不到任何关于它的结果。这个键在注册表中的什么位置,它的一些值是什么?
    【解决方案4】:

    我从未使用过 win 8,但在 win 10 中,您可以使用 InputScope 来控制使用的屏幕键盘:

    <TextBox Grid.Row="0"
             InputScope="Number" />
    <TextBox Grid.Row="1"
             InputScope="Default" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-22
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多