Solved

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

Posted on 2001-09-11
5
469 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 100 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 49

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 3

Expert Comment

by:sridhar_PJ
ID: 6478560
0
 
LVL 15

Expert Comment

by:ameba
ID: 6478933
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now