Search code examples
c#winformstouchscreen

Show on-screen keyboard on event in winforms?


I have a c# winforms application that will be installed on a touch-screen device (windows 10) and I'm wondering how I can make the Windows on-screen keyboard pop up when an event occurs (whenever I click on a text box)


Solution

  • depends on if it is in tablet mode, you can call OSK like this in your code, app must be run in admin mode to modify the registry key to allow for osk to be present.

    Add this code to the textBox_Click() event and that should open it up once the textbox is clicked.

    you can skip the registry value if the device will be in tablet mode.

    Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7", "EnableDesktopModeAutoInvoke", 1); // skip this if device is in tablet mode.
    string progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
    string onScreenKeyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
    process = System.Diagnostics.Process.Start(onScreenKeyboardPath);