قم بمسح كل ما لديك من الأكواد وأدرج موديول جديد ، حيث قمت بعمل توليفة تعمل للثلاثة أزرار ..
CODE
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VK_NUMLOCK = &H90
Private Const VK_CAPITAL = &H14
Private Const VK_SCROLL = &H91
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
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 GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Function CheckOnOff(ByVal v)
ReDim KeyboardBuffer(256) As Byte
GetKeyboardState KeyboardBuffer(0)
If KeyboardBuffer(v) And 1 Then CheckOnOff = True Else CheckOnOff = False
End Function
Public Sub ToggleButton(ByVal TurnOn As Boolean, ByVal v)
Dim bytKeys(255) As Byte, bOn As Boolean, typOS As OSVERSIONINFO
GetKeyboardState bytKeys(0)
bOn = bytKeys(v)
If bOn <> TurnOn Then
If typOS.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
bytKeys(v) = 1
SetKeyboardState bytKeys(0)
Else
keybd_event v, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
keybd_event v, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
End If
End If
End Sub
'------------------------------------------------------------------------
Sub NumLockToggle()
If CheckOnOff(VK_NUMLOCK) = False Then NumLockON Else NumLockOFF
End Sub
Sub NumLockON()
ToggleButton True, VK_NUMLOCK
End Sub
Sub NumLockOFF()
ToggleButton False, VK_NUMLOCK
End Sub
'------------------------------------------------------------------------
Sub CapsLockToggle()
If CheckOnOff(VK_CAPITAL) = False Then CapsLockON Else CapsLockOFF
End Sub
Sub CapsLockON()
ToggleButton True, VK_CAPITAL
End Sub
Sub CapsLockOFF()
ToggleButton False, VK_CAPITAL
End Sub
'------------------------------------------------------------------------
Sub ScrollLockToggle()
If CheckOnOff(VK_SCROLL) = False Then ScrollLockON Else ScrollLockOFF
End Sub
Sub ScrollLockON()
ToggleButton True, VK_SCROLL
End Sub
Sub ScrollLockOFF()
ToggleButton False, VK_SCROLL
End Sub