Share via


I want get input from onscreen keyboard

Question

Thursday, September 14, 2017 9:44 AM

i want to give input text to edit box through on screen keyboard kindly give a suggestion..

Rangaraj

All replies (5)

Friday, September 15, 2017 6:18 AM âś…Answered | 1 vote

Hi Rangaraj.p,

What language you want to use? I use vb.net to reply your thread.

You can try the following code to get text from on screen keyboard into Textbox.

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 TextBox2_Enter(sender As Object, e As EventArgs) Handles TextBox2.Enter
        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

Best Regards,

Cherry

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Thursday, September 14, 2017 10:38 AM | 3 votes

Hi rangaraj, 

you need to call the proces "osk.exe" 

here is a vb.net example

Process.Start("osk.exe");
Private Sub Form1_Load(sender As Object, e As EventArgs)
    AddHandler textBox1.GotFocus, AddressOf textBox1_GotFocus
End Sub

Private Sub textBox1_GotFocus(sender As Object, e As EventArgs)
    If textBox1.TabIndex > 0 Then
        System.Diagnostics.Process.Start("osk.exe")
    End If

End Sub

in c# 

private void button1_Click(object sender, EventArgs e)
{
    System.Diagnostics.Process.Start("osk.exe");
    //SetFocus to your TextBox here
    textBox1.Focus();
}

Kind regards

Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Friday, September 15, 2017 4:20 AM

Hi laurens vdb  

Yes That i did already. but when i pressed key in osk screen the text is not appear in text box...  

Rangaraj


Friday, September 15, 2017 6:19 AM

Hi Rangaraj,

Thank you for posting in MSDN forum.

This forum is about Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

As your issue is related to language development , I help you move this case to VB forum for dedicated support.

Thank you for your understanding,

Best Regards,

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Friday, September 15, 2017 5:49 PM

 I am not sure about Win8 or Win10 but,  in XP,  Vista,  and Win7,  the OSK is well registered and can be started by just using the filename as shown below.  I don't believe you would need to Disable/Enable the wow64 redirection if you use this....

    Private Sub TextBox1_Enter(sender As Object, e As EventArgs) Handles TextBox1.Enter
        Process.Start("osk.exe")
    End Sub

 If that is a problem on 64bit Win8 or 10,  then you may at least want to change the code a little.  In the msdn documents for the Wow64EnableWow64FsRedirection function it says that this function may not work reliably and that you should use the Wow64RevertWow64FsRedirection function instead.  In the "Revert" function document it also says this...

 ""The Wow64DisableWow64FsRedirection / Wow64RevertWow64FsRedirection function pair is a replacement for the functionality of the Wow64EnableWow64FsRedirection function.""

 The parameters of the two functions should also be IntPtr types,  not Long types.

Imports System.Runtime.InteropServices

Public Class Form1
    <DllImport("kernel32.dll")>
    Public Shared Function Wow64DisableWow64FsRedirection(ByRef OldValue As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

    <DllImport("kernel32.dll")>
    Public Shared Function Wow64RevertWow64FsRedirection(ByRef OldValue As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function


End Class

 

If you say it can`t be done then i`ll try it