Windows 8 Desktop App: Open tabtip.exe to secondary keyboard (for numeric textbox)
Asked Answered
P

4

9

We're working on a desktop WPF app that runs on Windows 7 tablets and are adding some Surface Pro units with windows 8 to the mix.

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.

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.

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.

Is there a command-line argument to tabtip.exe I can use to accomplish this?

Proselytism answered 26/3, 2013 at 20:24 Comment(0)
T
9

in HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7 (Windows 8) change the REG_DWORD KeyboardLayoutPreference value of 0 is the regular layout value of 1 is the split keyboard with the numberpad in the middle

the REG_DWORD LastUsedModalityWasHandwriting also has to be 0 or if 1, when tabtip is started again it will open with the pen handwriting area.

Tributary answered 6/7, 2013 at 6:51 Comment(3)
fantastic! This DWORD didn't exist in the registry for me already, so I had to create it. But it definitely has the desired effect.Proselytism
This works great for Windows 8 machines but in Windows 10 the TabTip.exe seems to reset all the registry settings when it is opened.Snapp
@Snapp Windows 10 opens the handwriting-view when a stylus is present, the typing-view, otherwise. Until now I have not found any possibilityies to start with handwriting-view when no stylus is present.Religionism
D
10

Following on from the answer @tymes provided, here is a quick console app which demonstrates opening the keyboard and changing various settings (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;
            }
        }
    }
}
Dorsey answered 16/7, 2014 at 9:32 Comment(3)
Hi Barrie, do you know how to get all the register Key Name for TabTip? I'm trying to get a key to enable caps when KeyBoard Open... Thank youClaustrophobia
Prior to showing the on-screen keyboard, you can simulate a press of caps lock if it isn't already on. I think that should workDorsey
The basic approach to checking caps lock and then enabling is outline here and hereDorsey
T
9

in HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7 (Windows 8) change the REG_DWORD KeyboardLayoutPreference value of 0 is the regular layout value of 1 is the split keyboard with the numberpad in the middle

the REG_DWORD LastUsedModalityWasHandwriting also has to be 0 or if 1, when tabtip is started again it will open with the pen handwriting area.

Tributary answered 6/7, 2013 at 6:51 Comment(3)
fantastic! This DWORD didn't exist in the registry for me already, so I had to create it. But it definitely has the desired effect.Proselytism
This works great for Windows 8 machines but in Windows 10 the TabTip.exe seems to reset all the registry settings when it is opened.Snapp
@Snapp Windows 10 opens the handwriting-view when a stylus is present, the typing-view, otherwise. Until now I have not found any possibilityies to start with handwriting-view when no stylus is present.Religionism
C
1

You may control input mode by registry setting for Tabtip. Look for the registry entry with name KeyboardLayoutPreference.

Cultivable answered 16/4, 2013 at 11:33 Comment(1)
I did a search in regedit for that key and received no results. I couldn't find any results on Google about it either. Where does this key go in the registry, and what are some values for it?Proselytism
A
1

I've never used win 8 but in win 10 you can use InputScope to control what on-screen keyboard is used:

<TextBox Grid.Row="0"
         InputScope="Number" />
<TextBox Grid.Row="1"
         InputScope="Default" />
Archive answered 20/6, 2016 at 0:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.