Is there a function that convert a keycode to a scancode?
I have a function/process that send scancode, I use this so that I can Send Keys to a Citrix Receiver. But every time I use that code, first I need to open a Visual Basic KeyBoard Program that determine what Scan Code is pressed.
VB6 Keyboard Hook code
Public Function KeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If nCode = HC_ACTION Then
CopyMemory kbstruct, ByVal lParam, LenB(kbstruct)
Debug.Print kbstruct.scanCode
End If
KeyboardProc = CallNextHookEx(Hook, nCode, wParam, lParam)
End Function
This is a function I used in sending key to a citrix receiver (cannot send ENTER/TAB any special key)
TypeInput("Test Text with ARROW UP", Keys.Up, 72)
TypeInput("Normal Text", 0, 0)
Private Sub Pause(Optional ByVal millisecondsTimeout As Integer = 100)
Application.DoEvents()
Threading.Thread.Sleep (millisecondsTimeout)
End Sub
Private Sub TypeInput(ByVal input As String, ByVal wVk As Short, ByVal wScan As Short)
SendKeys.SendWait(input)
Pause()
If (wVk > 0 And wScan > 0) Then
Dim inp As New INPUT
inp.Type = InputType.Keyboard
inp.u.ki = New KEYBDINPUT
inp.u.ki.wVk = wVk
inp.u.ki.wScan = wScan
inp.u.ki.time = 0
inp.u.ki.dwFlags = KEYEVENTF.KeyDown
inp.u.ki.dwExtraInfo = IntPtr.Zero
SendInput(1, inp, Marshal.SizeOf(GetType(Input)))
End If
End Sub
Thanks a lot.