Mat*_*ler 8 wpf desktop-application on-screen-keyboard windows-8
我们正在开发一个在Windows 7平板电脑上运行的桌面WPF应用程序,并且正在添加一些带有Windows 8的Surface Pro设备.
当TextBox获得焦点时,我们立即注意到不再显示小键盘图标.我们通过在所有TextBox的MouseDown事件上运行"tabtip.exe"来解决它.
我们有一些数字文本框(订单上的项目数量),并且想要打开屏幕键盘进行数字输入,但默认情况下会打开qwerty键.
我一直在寻找任何命令行参数,我可以传递给tabtip.exe来改变它的输入模式,但没有运气.对于使用都市风格的应用程序来说,这似乎是一项微不足道的任务,但在桌面方面是不可能的.
是否有tabtip.exe的命令行参数我可以用来完成这个?
从@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;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
在HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7
(Windows 8)中更改REG_DWORD KeyboardLayoutPreference
值0
是常规布局值1
是分割键盘与中间的数字键盘
REG_DWORD LastUsedModalityWasHandwriting
也必须是0
或者如果1
,当tabtip再次启动时,它将用笔手写区域打开.
归档时间: |
|
查看次数: |
11684 次 |
最近记录: |