Saberexcel - o site de quem precisa aprender macros microsoft excel vba
Estas declarações e a macro do aplicativo microsoft excel vba ativa o NUM LOOK and CAPSLOCK API
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
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
Sub CapsLockOn()
GetKeyboardState kbArray
kbArray.kbByte(VK_NUMLOCK) = 1
SetKeyboardState kbArray
End Sub
Sub CapsLockOff()
GetKeyboardState kbArray
kbArray.kbByte(VK_NUMLOCK) = 0
SetKeyboardState kbArray
End Sub
'- - - - - - - -
Declare Function GetKeyboardState Lib "User32" _
(pbKeyState As Byte) As Long
Declare Function SetKeyboardState Lib "User32" _
(lppbKeyState As Byte) As Long
Sub SetMyNumLock()
' NUMLOCK Ligado e CAPSLOCK desligado
Dim Res As Long
Dim KBState(0 To 255) As Byte
Res = GetKeyboardState(KBState(0))
KBState(&H90) = 1 ' num lock 1 = on, 0 = off
KBState(&H14) = 0 ' caps lock 1 = on, 0 = off
Res = SetKeyboardState(KBState(0))
End Sub
Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Escola Saberexcel VBA Estudos® - Treinamentos com Macros, Fórmulas e Funções.