M
MicrosoftNews
Hi,
I want to switch the "scroll" led with vba on and of with different buttons
....
I want to switch on and off the scroll led with the following code
-------------------------------------------------------------------------------------
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_OEM_SCROLL = &H91
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer
Sub SCROLL_aktiv() 'SCROLL-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
Sub SCROLL_inaktiv() ' SCROLL-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
----------------------------------------------------------------------------------------
with the scroll_aktiv procedure i can toggle between on and off. but it
should only switch on the led. with scroll_inaktiv i can't switch of the
led - and i don't know why
the following procedure for the num lock led works fine
------------------------------------------------------------------------------
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer
Sub NUM_TOGGLE()
' NUM-Lock drücken
' Zunächst niederdrücken und dann wieder loslassen
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End Sub
Sub NUM_aktiv() 'NUM-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
Sub NUM_inaktiv() ' NUM-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
I want to switch the "scroll" led with vba on and of with different buttons
....
I want to switch on and off the scroll led with the following code
-------------------------------------------------------------------------------------
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_OEM_SCROLL = &H91
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer
Sub SCROLL_aktiv() 'SCROLL-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
Sub SCROLL_inaktiv() ' SCROLL-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
----------------------------------------------------------------------------------------
with the scroll_aktiv procedure i can toggle between on and off. but it
should only switch on the led. with scroll_inaktiv i can't switch of the
led - and i don't know why
the following procedure for the num lock led works fine
------------------------------------------------------------------------------
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer
Sub NUM_TOGGLE()
' NUM-Lock drücken
' Zunächst niederdrücken und dann wieder loslassen
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End Sub
Sub NUM_aktiv() 'NUM-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
Sub NUM_inaktiv() ' NUM-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub