I need to read the NumLock status in VB.net.
After some Googling I found the following Class:
Public Class KeyState
Declare Function GetKeyboardState Lib "user32" Alias "GetKeyboardState" (ByVal pbKeyState() As Byte) As Long
Private KeyCode As Integer
Public Sub New(ByVal keycode As Integer)
Me.KeyCode = keycode
Public Function KeyState() As Boolean
Dim state(256) As Byte
Return (iif(state(Me.KeyCode) = 1, True, False))
This works fine if the App has focus, but does not read the key correctly if another App as focus.
Is there a way to do this?