Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Dim kbArray As KeyboardBytes
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Const VK_NUMLOCK = &H90
Private Function Get_Value() As Boolean
Get_Value = GetKeyState(VK_NUMLOCK) And 1 = 1
End Function
Private Sub Set_Value(boolVal As Boolean)
Call GetKeyboardState(kbArray)
kbArray.kbByte(VK_NUMLOCK) = Abs(boolVal)
Call SetKeyboardState(kbArray)
End Sub
Sub change_NUMLOCK()
Dim State_Numlock As Boolean
State_Numlock = Get_Value
If State_Numlock = True Then
Call Set_Value(False)
Else
Call Set_Value(True)
End If
End Sub