Call On-Screen Keyboard(OSK) using vb.net

KiRa picture KiRa · Mar 6, 2017 · Viewed 9.6k times · Source

I am using this code below to call On-Screen Keyboard(OSK)

Process.Start("C:\Windows\System32\OSK.EXE")

but as you can see below I got an error. But if I manually open it, it's working fine.

And it is possible to call the OSK but only numeric display (0 - 9) enter image description here

Answer

Apoorva Vyas picture Apoorva Vyas · Sep 11, 2017
Public Class Form1

    Declare Function Wow64DisableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean
    Declare Function Wow64EnableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean
    Private osk As String = "C:\Windows\System32\osk.exe"
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim old As Long
        If Environment.Is64BitOperatingSystem Then
            If Wow64DisableWow64FsRedirection(old) Then
                Process.Start(osk)
                Wow64EnableWow64FsRedirection(old)
            End If
        Else
            Process.Start(osk)
        End If
    End Sub
End Class