Option Explicit
#If VBA7 Then
Declare PtrSafe Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
#Else
Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
#End If
Function changeCapslock(boulboul As Long)
Dim Etat As Long, KBState(0 To 255) As Byte, CapsLock As Long
Etat = GetKeyboardState(KBState(0)): CapsLock = KBState(&H14) And 1
If Not boulboul = CapsLock Then CreateObject("wscript.shell").SendKeys "{CAPSLOCK}"
End Function
Sub CapslockOn(): changeCapslock 1: End Sub
Sub CapslockOff(): changeCapslock 0: End Sub