I'm trying to understand the output of GetKeyboardState but i cannot.
I tried to interpret the output with the following code,
An application can use the virtual-key code constants VK_SHIFT, VK_CONTROL and VK_MENU as indices into the array pointed to by lpKeyState. This gives the status of the SHIFT, CTRL, or ALT keys
According to above documentation, i was expect when i press Shift, i see the item in the index VK_SHIFT (16) reflects the Shift key state, but actually the item in index 40 is reflect the Shift key state
I want to understand the output of GetKeyboardState in order to send a custom keystate to another API function (ToUnicodeEx)
I tried to interpret the output with the following code,
Code:
Option Strict On
Option Explicit On
Imports System.Text
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll", ExactSpelling:=True)>
Private Shared Function GetKeyboardState(ByVal keyStates() As Integer) As Boolean
End Function
Private WithEvents Timer1 As New Timer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Interval = 100
Timer1.Start()
Me.TopMost = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim k(255) As Integer
GetKeyboardState(k)
ListBox1.Items.Clear()
For j As Integer = 0 To 255
If k(j) <> 0 Then
ListBox1.Items.Add(j & " = " & k(j))
End If
Next
End Sub
End Class
Quote:
An application can use the virtual-key code constants VK_SHIFT, VK_CONTROL and VK_MENU as indices into the array pointed to by lpKeyState. This gives the status of the SHIFT, CTRL, or ALT keys
I want to understand the output of GetKeyboardState in order to send a custom keystate to another API function (ToUnicodeEx)