1 Attachment(s)
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.
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
Im open to any comments....
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
guys please give me your comments...
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
i found this gd but i made a few adjustments to it instead of having them as msgboxs i put them into a listbox then modified it so instead of it multiplying the values everytime you click on the button, it wipes the previous values and then calls the command again.
VB Code:
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Sub cmd_state_Click()
If List_state.ListCount = 0 Then
If GetKeyState(vbKeyCapital) = 0 Then
List_state.AddItem "Capital OFF"
Else
List_state.AddItem "Capital ON"
End If
If GetKeyState(vbKeyNumlock) = 0 Then
List_state.AddItem "NumLock OFF"
Else
List_state.AddItem "NumLock ON"
End If
If GetKeyState(vbKeyInsert) = 0 Then
List_state.AddItem "Insert OFF"
Else
List_state.AddItem "Insert ON"
End If
If GetKeyState(vbKeyScrollLock) = 0 Then
List_state.AddItem "Scroll Lock OFF"
Else
List_state.AddItem "Scroll Lock ON"
End If
Else:
List_state.Clear
Call cmd_state_Click
End If
End Sub
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
thank you very much for your suggestion...but instead of the listbox, we can update label caption for these key status...will incorporate that...but have you checked the attached zip file?
Re: VB6-Capturing Caps Lock, Scroll Lock, Num Lock and Insert Key Status
hey, this was really good when i found it, it seemed cool, and the other week when i got bored i found the file, and developed on it so much, there is a splash screen at the begging letting you change loads of settings and the form that tells you about the states sits in the top right corner and it aslo sits on top of all other programs or windows you have open, good if your writing in a text editor and dont want to look down at the keyboard to check the states.
i would upload the files and the exe but as i havent uploaded onto this site before,i dont know :ehh: , could some one message me and tell me how and ill put it up in a new thread. i just thought someone might wanna make use of the code. i will also refer back to this thread in the new one.
msg please
will :wave: