1

I am trying to write a desktop application where if I click certain buttons OSK will appear. I try calling it with the following code:

System.Diagnostics.Process.Start("osk.exe");

But the following error displays each time:

"Could not start On Screen Keyboard"

Why would that happen?

UPDATE:

If I change the debugging mode from any CPU to 64x the issue is resolved. But I would like for the OSK to show up automatically when a text is selected in tablet mode, also why is there any way to get the tablet mode OSK to show up?

Phia-CM
  • 67
  • 1
  • 9
  • What exactly are the "certain buttons" that you wish the OSK to appear for? Usually, the OSK *should* appear when a `` is focused (and a touch-screen is detected). Are you defining a "tablet mode" yourself, or is the device you're using a actually tablet? Could you tell us a bit more about the scope of your app and what you're trying to achieve? – Geoff James Aug 15 '16 at 18:17

2 Answers2

3

This is my experience in getting OSK started using System.Diagnostics.Process.Start("osk.exe"). I have only tested on Windows 7 64-bit and Windows 10 64-bit and using Visual Studio 2015. The behavior is different on the two Windows versions.

There are three relevant build options:

  1. Any CPU, Prefer 32-bit checked (default):

On Windows 7 using osk.exe works ok.

On Windows 10 none of osk.exe, \Windows\System32\osk.exe, or \windows\SysWOW64\osk.exe works (probably your situation).

  1. Any CPU, Prefer 32-bit not checked:

On Windows 7 using osk.exe works ok.

On Windows 10, only \Windows\System32\osk.exe works.

  1. x64:

On Windows 10, osk.exe and \Windows\System32\osk.exe work.

The platform target (Any CPU) and the checkbox for Prefer 32-bit are in Project Properties, Build tab. The default is to have Prefer 32-bit checked (makes smaller executables). This means the application most likely runs in 32-bit mode on a 64-bit system. In the Task Manager you will see a *32 on Windows 7 and a (32-bit) on Windows 10.

With it unchecked, the application will run in 64-bit mode on a 64-bit system and calling \Windows\System32\osk.exe will find everything it needs. I haven't investigated why the behavior changed in Windows 10, but the bottom line is to use Any CPU with Prefer 32-bit unchecked and specify the full path to OSK, i.e. \Windows\System32\osk.exe.

\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe will start TabTip.

Kenneth Evans
  • 2,179
  • 19
  • 26
0

I discovered an undocumented COM interface for controlling the touch keyboard. Check the code here https://stackoverflow.com/a/40921638/332528

Community
  • 1
  • 1
torvin
  • 6,515
  • 1
  • 37
  • 52