vb.elmar
October 19th, 2001, 02:53 PM
Hello
i need a function to detect the "scroll lock state".
I want to detect the state of the green scroll-lock
keyboard LED (OFF or ON).
The code below works, but when starting another
application like notepad, the scroll lock state no more
is displayed correctly by vb.
Only when closing notepad (i use the GetKeyboardState api)
the code works.
Using another api (GetAsyncKeyState)
i could detect the scroll lock state,
when notepad is started, but i only can
see that the key is pressed at this moment.
I can not see the scroll lock state
(is the scroll LED
on or of at this time?)
Can i detect the state or
the state of the scroll lock LED, when
another application is running ?
================================
needs 1 timer on a form
================================
Private Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_CAPITAL = &H14
Private Sub Form_Load()
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
Dim State As Boolean
Dim Keys(0 To 255) As Byte
Call GetKeyboardState(Keys(0))
State = Keys(VK_SCROLL)
Caption = State & " " & Rnd
End Sub
i need a function to detect the "scroll lock state".
I want to detect the state of the green scroll-lock
keyboard LED (OFF or ON).
The code below works, but when starting another
application like notepad, the scroll lock state no more
is displayed correctly by vb.
Only when closing notepad (i use the GetKeyboardState api)
the code works.
Using another api (GetAsyncKeyState)
i could detect the scroll lock state,
when notepad is started, but i only can
see that the key is pressed at this moment.
I can not see the scroll lock state
(is the scroll LED
on or of at this time?)
Can i detect the state or
the state of the scroll lock LED, when
another application is running ?
================================
needs 1 timer on a form
================================
Private Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_CAPITAL = &H14
Private Sub Form_Load()
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
Dim State As Boolean
Dim Keys(0 To 255) As Byte
Call GetKeyboardState(Keys(0))
State = Keys(VK_SCROLL)
Caption = State & " " & Rnd
End Sub