Saber Excel - o site das macros
Essas declarações ( api ) e macros do Aplicativo Microsoft Excel VBA(Visual Basic Application), acendem e apagam as luzes do teclado
Const VK_CAPITAL = &H14
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_USED = VK_SCROLL
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
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
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim kbArray As KeyboardBytes, CapsLock As Boolean, kbOld As KeyboardBytes
Sub Piscar()
For I = 0 To 5
GetKeyboardState kbOld
Apagar VK_CAPITAL
Apagar VK_NUMLOCK
Apagar VK_SCROLL
Sleep 1000
Acender VK_NUMLOCK
Sleep 100
Acender VK_CAPITAL
Sleep 100
Acender VK_SCROLL
Sleep 300
Apagar VK_NUMLOCK
Sleep 100
Apagar VK_CAPITAL
Sleep 100
Apagar VK_SCROLL
Sleep 500
Acender VK_NUMLOCK
Acender VK_SCROLL
Sleep 200
Apagar VK_NUMLOCK
Apagar VK_SCROLL
Sleep 200
Acender VK_NUMLOCK
Acender VK_SCROLL
Sleep 200
Apagar VK_NUMLOCK
Apagar VK_SCROLL
Sleep 200
Acender VK_CAPITAL
Sleep 200
Apagar VK_CAPITAL
Sleep 200
Acender VK_CAPITAL
Sleep 200
Apagar VK_CAPITAL
Sleep 200
Acender VK_NUMLOCK
Acender VK_SCROLL
Sleep 200
Apagar VK_NUMLOCK
Apagar VK_SCROLL
Sleep 200
Acender VK_NUMLOCK
Acender VK_SCROLL
Sleep 200
Apagar VK_NUMLOCK
Apagar VK_SCROLL
Sleep 200
Acender VK_CAPITAL
Sleep 400
Apagar VK_CAPITAL
Sleep 200
Acender VK_SCROLL
Sleep 100
Acender VK_CAPITAL
Sleep 100
Acender VK_NUMLOCK
Sleep 300
Apagar VK_NUMLOCK
Sleep 100
Apagar VK_CAPITAL
Sleep 100
Apagar VK_SCROLL
Next I
Voltar
End Sub
'-------------------------------'
Sub Acender(vkKey As Long)
GetKeyboardState kbArray
kbArray.kbByte(vkKey) = 1
SetKeyboardState kbArray
End Sub
'-------------------------------'
Sub Apagar(vkKey As Long)
GetKeyboardState kbArray
kbArray.kbByte(vkKey) = 0
SetKeyboardState kbArray
End Sub
'-------------------------------'
Sub Voltar()
SetKeyboardState kbOld
End Sub
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA(Visual Basic Application) com Saberexcel