I found this code which work fine without any errors:
private void btnScreenkeyboar_Click(object sender, EventArgs e)
{
try
{
StartOSK();
}
catch (Exception error)
{
string err = error.ToString();
}
}
static void StartOSK()
{
string windir = Environment.GetEnvironmentVariable("WINDIR");
string osk = null;
if (osk == null)
{
osk = Path.Combine(Path.Combine(windir, "sysnative"), "osk.exe");
if (!File.Exists(osk))
osk = null;
}
if (osk == null)
{
osk = Path.Combine(Path.Combine(windir, "system32"), "osk.exe");
if (!File.Exists(osk))
{
osk = null;
}
}
if (osk == null)
osk = "osk.exe";
Process.Start(osk);
}