VB Code:
Imports System.Runtime.InteropServices
Public Class KeypadControl
<DllImport("coredll")> Public Shared Sub keybd_event(ByVal vk As Byte, ByVal sc As Byte, ByVal Flags As Integer, ByVal dwExtraInfo As Integer)
End Sub
Public Sub SendKBChar(ByVal ch As Char)
If ch = "." Then
keybd_event(&HBE, 0, 0, 0)
keybd_event(&HBE, 0, &H2, 0)
ElseIf ch = "T" Then
keybd_event(9, 0, 0, 0)
keybd_event(9, 0, &H2, 0)
Else
Dim vk As Byte
vk = BitConverter.GetBytes(ch)(0) 'convert character to unicode
keybd_event(vk, 0, 0, 0)
keybd_event(vk, 0, &H2, 0)
End If
End Sub
Private Sub Panel1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel1.Click
SendKBChar("1")
End Sub
Private Sub Panel2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel2.Click
SendKBChar("2")
End Sub
Private Sub Panel3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel3.Click
SendKBChar("3")
End Sub
Private Sub Panel4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel4.Click
SendKBChar("4")
End Sub
Private Sub Panel5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel5.Click
SendKBChar("5")
End Sub
Private Sub Panel6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel6.Click
SendKBChar("6")
End Sub
Private Sub Panel10_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel10.Click
SendKBChar("0")
End Sub
Private Sub Panel7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel7.Click
SendKBChar("7")
End Sub
Private Sub Panel8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel8.Click
SendKBChar("8")
End Sub
Private Sub Panel9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel9.Click
SendKBChar("9")
End Sub
Private Sub Panel10_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel11.Click
SendKBChar(".")
End Sub
Private Sub Panel12_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel12.Click
SendKBChar("T") 'sends tab key, not T
End Sub
End Class