0
votes

I develop a WPF application that must support touch (including a floating keyboard that appears upon touching input fields such as textboxes) and also must support running my WPF app exe file in a shell mode.

I run my WPF app exe file in shell mode as following:

enter image description here

The code I use for opening the floating keyboard via touch is as following:

txtUserName.TouchUp += ShowKeyboard;
txtUserName.LostFocus += CloseKeyboardProcess;

And the implementation of those two methods is as following:

private void ShowKeyboard(object sender, RoutedEventArgs e)
{
        var touchKeyboardPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) +
                                @"\Microsoft Shared\ink\TabTip.exe";
        _keyProccesl = Process.Start(touchKeyboardPath);
}

    [DllImport("user32.dll")]
    public static extern int FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll")]
    public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);

    private void CloseKeyboardProcess(object sender, RoutedEventArgs e)
    {
        try
        {
            var iHandle = FindWindow("IPTIP_Main_Window", "");
            if (iHandle > 0)
            {
                SendMessage(iHandle, 0x0112, 0xF060, 0);
            }
        }
        catch (Exception ex)
        {
            Logger.WriteErr(LogCode.WIN_KEYBOARD_CLOSE_FAILED, ex);
        }
    }

The _keyProcess1 is just a private member of the class:

 private Process _keyProccesl;

Now, let me describe the problem I've encounterd:

When I run my WPF app in a regular mode (NOT in a shell mode as described above), everything works perfectly: When I touch a textbox, the floating keyboard appears. When I get out of the text box (losing focus), the floating keyboard indeed closes.

The problem occurs ONLY when I run my WPF app exe file in a shell mode. When I do that, NO floating keyboard appears when I touch an input textbox (same action that has worked perfectly in a regular non-shell mode).

Now let me describe all the actions that I've tried to apply to make this work in a shell mode:

  1. Adding the following two reg entries did NOT fix the problem: HKCU\Software\Microsoft\TabletTip\1.7\EnableDesktopModeAutoInvoke = 1 HKCU\Software\Microsoft\windows\CurrentVersion\ImmersiveShell\TabletMode = 1

Also, NOT these ones:

HKLM\Software\Microsoft\TabletTip\1.7\EnableDesktopModeAutoInvoke = 1 HKLM\Software\Microsoft\windows\CurrentVersion\ImmersiveShell\TabletMode = 1

  1. I've tried to apply a Nuget package as described here:

OnScreen keyboard issue with WPF Classic Windows App as Custom Shell on Windows 10 Pro

The nuget package of:

Osklib.Wpf

Did NOT work.

  1. I've tried to apply a Nuget package as described here:

https://www.nuget.org/packages/WPFTabTip/

The nuget package of:

WPFTabTip

Did NOT work.

Note that all these 3 work well in a regular non-shell mode.


The ONLY thing that has worked for me is trying to open the following process:

(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");

This is the ONLY thing that works for me in a shell mode, but this is NOT a good solution for me because it opens the keyboard as a separate window (on screen keyboard), and NOT as an embedded keyboard into my WPF app as the TabTip.exe does.

Your kind assistance will be greatly appreciated, thank you!

1

1 Answers

0
votes

Apparently, the process of the floating keyboard, named TabTip, depends on the process of Windows’ Explorer.exe, which is not available in shell mode.

I've ended up implementing my own custom virtual keyboard control.

Another option is not use the shell mode, and just use windows with group-policies (this can be useful for locking down computers, restricting access to specific folders, control panel applets, and applications).