Voici le code modifié fonctionnant sous windows 2000 adv serveur + VB 6 SP 5 FR :
Const VK_CAPITAL = &H14
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_USED = VK_SCROLL
' Const des touches étendues
Private Const KEYEVENTF_EXTENDEDKEY = &H1
' Const du relachement
Const KEYEVENTF_KEYUP = &H2
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)
' API simulant l'appuye d'une touche quelconque
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Dim kbArray As KeyboardBytes, CapsLock As Boolean, kbOld As KeyboardBytes
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'Get the current keyboardstate
GetKeyboardState kbOld
'Hide the form
Me.Hide
MsgBox "Keep your eyes on the little num-, shift- and scrolllock lights on the keyboard."
TurnOff VK_CAPITAL
TurnOff VK_NUMLOCK
TurnOff VK_SCROLL
Sleep 1000
TurnOn VK_NUMLOCK
Sleep 100
TurnOn VK_CAPITAL
Sleep 100
TurnOn VK_SCROLL
Sleep 300
TurnOff VK_NUMLOCK
Sleep 100
TurnOff VK_CAPITAL
Sleep 100
TurnOff VK_SCROLL
Sleep 500
TurnOn VK_NUMLOCK
TurnOn VK_SCROLL
Sleep 200
TurnOff VK_NUMLOCK
TurnOff VK_SCROLL
Sleep 200
TurnOn VK_NUMLOCK
TurnOn VK_SCROLL
Sleep 200
TurnOff VK_NUMLOCK
TurnOff VK_SCROLL
Sleep 200
TurnOn VK_CAPITAL
Sleep 200
TurnOff VK_CAPITAL
Sleep 200
TurnOn VK_CAPITAL
Sleep 200
TurnOff VK_CAPITAL
Sleep 200
TurnOn VK_NUMLOCK
TurnOn VK_SCROLL
Sleep 200
TurnOff VK_NUMLOCK
TurnOff VK_SCROLL
Sleep 200
TurnOn VK_NUMLOCK
TurnOn VK_SCROLL
Sleep 200
TurnOff VK_NUMLOCK
TurnOff VK_SCROLL
Sleep 200
TurnOn VK_CAPITAL
Sleep 400
TurnOff VK_CAPITAL
Sleep 200
TurnOn VK_NUMLOCK
Sleep 100
TurnOn VK_CAPITAL
Sleep 100
TurnOn VK_SCROLL
Sleep 300
TurnOff VK_SCROLL
Sleep 100
TurnOff VK_CAPITAL
Sleep 100
TurnOff VK_NUMLOCK
Sleep 1000
Unload Me
End Sub
Private Sub TurnOn(vkKey As Long)
keybd_event vkKey, 69, KEYEVENTF_EXTENDEDKEY Or 0, 0
End Sub
Private Sub TurnOff(vkKey As Long)
keybd_event vkKey, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
'restore the old keyboard state
SetKeyboardState kbOld
End Sub