Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CAPS lock key

Status
Not open for further replies.

fingers

Programmer
Nov 17, 2000
17
0
0
How can I detect/change the status of the CAPS lock key in VB6?
 
Certainly. You'll find a good example here:


Hope to help.
VCA.gif

Alt255@Vorpalcom.Intranets.com
 
To change :

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 CommandButton to your form (named Command1).
'Insert the following code to your module:

Declare Sub GetKeyboardState Lib "user32" (lpKeyState As Any)
Declare Sub SetKeyboardState Lib "user32" (lpKeyState As Any)
Public Const VK_CAPITAL = &H14
Public Const VK_NUMLOCK = &H90

'Insert the following code to your form:

Private Sub Command1_Click()
ReDim KeyboardBuffer(256) As Byte
GetKeyboardState KeyboardBuffer(0)
'This example show you how to press the Caps Lock button. if you want
'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
'with 'VK_NUMLOCK'.
If KeyboardBuffer(VK_CAPITAL) And 1 Then
KeyboardBuffer(VK_CAPITAL) = 0
Else
KeyboardBuffer(VK_CAPITAL) = 1
End If
SetKeyboardState KeyboardBuffer(0)
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top