wpf Windows 8 桌面应用程序:打开 tabtip.exe 到辅助键盘(用于数字文本框)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15646684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows 8 Desktop App: Open tabtip.exe to secondary keyboard (for numeric textbox)
提问by Matthew Fotzler
We're working on a desktop WPFapp that runs on Windows 7 tablets and are adding some Surface Pro units with windows 8 to the mix.
我们正在开发可在 Windows 7 平板电脑上运行的桌面 WPF应用程序,并且正在添加一些带有 Windows 8 的 Surface Pro 设备。
We noticed immediately that the little keyboard icon no longer displays when a TextBox receives focus. We solved it by running "tabtip.exe" on the MouseDown event for all TextBoxes.
我们立即注意到,当 TextBox 获得焦点时,小键盘图标不再显示。我们通过在所有文本框的 MouseDown 事件上运行“tabtip.exe”来解决它。
We have some numeric textboxes though (quantity for an item on an order), and want to open the on-screen keyboard for numeric entry, but it opens with qwerty keys by default.
虽然我们有一些数字文本框(订单上项目的数量),并且想要打开屏幕键盘进行数字输入,但默认情况下它会使用 qwerty 键打开。
I have been searching extensively for any command-line arguments I can pass to tabtip.exe to change its input mode, but have had no luck. This seems like a trivial task with a metro-style app, but impossible on the desktop side.
我一直在广泛搜索可以传递给 tabtip.exe 以更改其输入模式的任何命令行参数,但没有成功。这对于 Metro 风格的应用程序来说似乎是一项微不足道的任务,但在桌面端是不可能的。
Is there a command-line argument to tabtip.exe I can use to accomplish this?
我可以使用 tabtip.exe 的命令行参数来完成此操作吗?
采纳答案by tymes
in HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7(Windows 8)
change the REG_DWORD KeyboardLayoutPreferencevalue of 0is the regular layout
value of 1is the split keyboard with the numberpad in the middle
在HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7(Windows 8) 中更改 REG_DWORDKeyboardLayoutPreference值0是常规布局值1是中间数字键盘的拆分键盘
the REG_DWORD LastUsedModalityWasHandwritingalso has to be 0or if 1, when tabtip is started again it will open with the pen handwriting area.
REG_DWORDLastUsedModalityWasHandwriting也必须是0,否则1,当再次启动 tabtip 时,它将使用钢笔手写区域打开。
回答by Barrie
Following on from the answer @tymes provided, here is a quick console app which demonstrates opening the keyboard and changing various settings (C#).:
继@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;
}
}
}
}
回答by S?awomir Leszczyński
You may control input mode by registry setting for Tabtip. Look for the registry entry with name KeyboardLayoutPreference.
您可以通过 Tabtip 的注册表设置来控制输入模式。查找名为 KeyboardLayoutPreference 的注册表项。
回答by Johan Larsson
I've never used win 8 but in win 10 you can use InputScopeto control what on-screen keyboard is used:
我从未使用过 win 8,但在 win 10 中,您可以使用InputScope来控制使用的屏幕键盘:
<TextBox Grid.Row="0"
InputScope="Number" />
<TextBox Grid.Row="1"
InputScope="Default" />

