Link to home
Start Free TrialLog in
Avatar of f_asmaa
f_asmaa

asked on

Virtual keyboard

Hello,

I need to implement virtual keyboard in VB.NET. It must send its characters to the current textbox or control
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

try this sample code in your form....
 
  Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        Const WM_KEYDOWN As Integer = &H100
        Const WM_SYSKEYDOWN As Integer = &H104
        Dim e As System.EventArgs

        If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
            Select Case (keyData)
                'The Number Key Pads, 10 key and regular 0-9 keys
            Case Keys.NumPad0, Keys.D0
                Case Keys.NumPad1, Keys.D1
                Case Keys.NumPad2, Keys.D2
                Case Keys.NumPad3, Keys.D3
                Case Keys.NumPad4, Keys.D4
                Case Keys.NumPad5, Keys.D5
                Case Keys.NumPad6, Keys.D6
                Case Keys.NumPad7, Keys.D7
                Case Keys.NumPad8, Keys.D8
                Case Keys.NumPad9, Keys.D9
                Case Keys.Down
                    MyStr = RichTextBox1.SelectionType = RichTextBoxSelectionTypes.Object
                    'The Other Number Key Pads keys
                Case Keys.Add, Keys.Oemplus
                Case Keys.Divide, Keys.OemQuestion
                Case Keys.Multiply, Keys.X
                Case Keys.Subtract, Keys.OemMinus
                Case Keys.Decimal
                Case Keys.Enter

                Case Keys.Back Or (Keys.Alt Or Keys.Back)
                Case (Keys.Alt Or Keys.D1) Or (Keys.Alt Or Keys.NumPad1)
                Case (Keys.Alt Or Keys.Oemplus)
                Case (Keys.Alt Or Keys.C)
                Case (Keys.Alt And Keys.Add)
                Case (Keys.Alt Or Keys.Q)
                Case (Keys.Alt Or Keys.D5)
                Case (Keys.Alt Or Keys.R)
                Case (Keys.Alt Or Keys.E)
                    'Do something
                Case Keys.C, Keys.Escape  'Use for clearing display
                   'Do something
            End Select
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function
Hi,

If you just want to simulate key strokes, then use this simple function :

SendKeys.Send(YourString)
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iboutchkine
iboutchkine

If you are using WIn XP, it already has a virtual keyboard. Go to Start-Run and type osk. You can call this from your app. Why do you need to reinvent  a wheel?
Avatar of f_asmaa

ASKER

Because I want to disable some keys in Windows Virtual keyboard
Hi, how i can send Num Pad 0

I need check Num lock status and Active for Send this Key.

Thank you