gpt4 book ai didi

wpf - Windows 8 桌面应用程序 : Open tabtip. exe 到辅助键盘(用于数字文本框)

转载 作者:行者123 更新时间:2023-12-04 05:13:15 26 4
gpt4 key购买 nike

我们正在开发 桌面 WPF 在 Windows 7 平板电脑上运行的应用程序,并将一些带有 Windows 8 的 Surface Pro 单元添加到组合中。

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

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

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

我可以使用 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;
}
}
}
}

关于wpf - Windows 8 桌面应用程序 : Open tabtip. exe 到辅助键盘(用于数字文本框),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15646684/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com