1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Option Explicit
''''********************************************************************************''''
' Procédure utilisée pour simuler l'appuie des touches CapsLock, Numlock et ScrollLock
''''********************************************************************************''''
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As _
Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) _
As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As _
Integer
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" _
(ByVal wCode As Long, ByVal wMapType As Long) As Long
Public Const VK_NUMLOCK = &H90
Public Const VK_SCROLL = &H91
Public Const VK_CAPITAL = &H14
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Public Sub SetKeyState(ByVal Key As Long, ByVal State As Boolean)
keybd_event Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or 0, 0
keybd_event Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
If Key = 20 And State = False Then
keybd_event 16, 0, 0, 0
keybd_event 16, 0, 2, 0
End If
End Sub
Public Property Get CapsLock() As Boolean
CapsLock = GetKeyState(VK_CAPITAL) = 1
End Property
Public Property Let CapsLock(ByVal Value As Boolean)
SetKeyState VK_CAPITAL, Value
End Property
Public Property Get NumLock() As Boolean
NumLock = GetKeyState(VK_NUMLOCK) = 1
End Property
Public Property Let NumLock(ByVal Value As Boolean)
SetKeyState VK_NUMLOCK, Value
End Property
Public Property Get ScrollLock() As Boolean
ScrollLock = GetKeyState(VK_SCROLL) = 1
End Property
Public Property Let ScrollLock(ByVal Value As Boolean)
SetKeyState VK_SCROLL, Value
End Property |
Partager