|
-
Dec 4th, 2006, 06:29 AM
#1
VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
VB Code:
'Include this line in your General Declaration of a Form
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
'Add a command button to your form and paste this code into it
Private Sub Command1_Click()
If GetKeyState(vbKeyCapital) = 0 Then
MsgBox "Capital OFF"
Else
MsgBox "Capital ON"
End If
If GetKeyState(vbKeyNumlock) = 0 Then
MsgBox "NumLock OFF"
Else
MsgBox "NumLock ON"
End If
If GetKeyState(vbKeyInsert) = 0 Then
MsgBox "Insert OFF"
Else
MsgBox "Insert ON"
End If
If GetKeyState(vbKeyScrollLock) = 0 Then
MsgBox "Scroll Lock OFF"
Else
MsgBox "Scroll Lock ON"
End If
End Sub
A sample project with this code and a timer to update the key status in the labels, attached in zip file format.
Last edited by ganeshmoorthy; Dec 5th, 2006 at 05:46 AM.
Reason: Edit: Sample project attached
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|