Results 1 to 9 of 9

Thread: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status

Threaded View

  1. #1

    Thread Starter
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status

    VB Code:
    1. 'Include this line in your General Declaration of a Form
    2. Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    3. 'Add a command button to your form and paste this code into it
    4. Private Sub Command1_Click()
    5.     If GetKeyState(vbKeyCapital) = 0 Then
    6.         MsgBox "Capital OFF"
    7.     Else
    8.         MsgBox "Capital ON"
    9.     End If
    10.     If GetKeyState(vbKeyNumlock) = 0 Then
    11.         MsgBox "NumLock OFF"
    12.     Else
    13.         MsgBox "NumLock ON"
    14.     End If
    15.     If GetKeyState(vbKeyInsert) = 0 Then
    16.         MsgBox "Insert OFF"
    17.     Else
    18.         MsgBox "Insert ON"
    19.     End If
    20.     If GetKeyState(vbKeyScrollLock) = 0 Then
    21.         MsgBox "Scroll Lock OFF"
    22.     Else
    23.         MsgBox "Scroll Lock ON"
    24.     End If
    25. End Sub
    A sample project with this code and a timer to update the key status in the labels, attached in zip file format.
    Attached Files Attached Files
    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
  •  



Click Here to Expand Forum to Full Width