GHGFSJD
Messages postés
113
Date d'inscription
samedi 11 novembre 2000
Statut
Membre
Dernière intervention
16 août 2008
7 juil. 2008 à 08:32
Bonjour,
Merci a tous, j'ai trouver ce code qui correspond exactement a ma recherche et je tenais a vous en faire profiter:
Auteur : avigeilpro
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
Et voici comment il s'utilise :
If CapsLock True Then CapsLock False
If NumLock True Then NumLock False
If ScrollLock True then ScrollLock False