Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Toggle Caps Lock, Scroll Lock and Num Lock?

Posted on 2001-09-11
5
Medium Priority
?
506 Views
Last Modified: 2012-05-04
Dear Friends,
    My VB Applications form contains Billingual fonts for support to local Language. Whenever Focus moves to that text (Which is meant to show text in local format and keyborad also be set to local lang support ). To achive this I have to press Eithrt Num/Scroll/Caps Key. But Instead I want my application to do this.
    I think I need to call some API's. Anyone who knows please reply.
    Thanks,
               bhatul
0
Comment
Question by:bhatul
5 Comments
 
LVL 1

Accepted Solution

by:
jtjcomp earned 400 total points
ID: 6475124
This code cycles through the three buttons

Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
Private Const VK_CAPITAL = &H14

Dim State As Long
Dim ted(0 To 255) As Byte


Private Sub Command1_Click()
    Timer1.Interval = 500
End Sub


Private Sub Form_Load()
    State = 1
End Sub

Private Sub Timer1_Timer()
    Select Case State
        Case 1
            'this sets it on
            ted(VK_NUMLOCK) = 1
            SetKeyboardState ted(0)
            ted(VK_CAPITAL) = 0
            SetKeyboardState ted(0)
            ted(VK_SCROLL) = 0
            SetKeyboardState ted(0)
        Case 2
            ted(VK_NUMLOCK) = 0
            SetKeyboardState ted(0)
            ted(VK_CAPITAL) = 1
            SetKeyboardState ted(0)
            ted(VK_SCROLL) = 0
            SetKeyboardState ted(0)
        Case 3
            ted(VK_NUMLOCK) = 0
            SetKeyboardState ted(0)
            ted(VK_CAPITAL) = 0
            SetKeyboardState ted(0)
            ted(VK_SCROLL) = 1
            SetKeyboardState ted(0)
    End Select
   
    If State = 3 Then
        State = 1
    Else
        State = State + 1
    End If
   
   
   

End Sub
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 6478206
Hi bhatul,

Some interesting link here:

Activating CapsLock, NumLock, ScrollLock and PrintScreen on NT/2000: http://www.mvps.org/vbnet/code/system/capslocknt.htm

Activating CapsLock and NumLock on Win9x: http://www.mvps.org/vbnet/code/system/capslock.htm

'Hope will help.
0
 
LVL 2

Expert Comment

by:Lunchy
ID: 6478462
bhatul, it is to your advantage to reject an answer immediately if it does not completely satisfy your requirements.

Lunchy
Friendly Neighbourhood Community Support Moderator
0
 
LVL 15

Expert Comment

by:ameba
ID: 6478933
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question