Solved

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

Posted on 2001-09-11
5
465 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 15

Expert Comment

by:ameba
Comment Utility
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

743 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

15 Experts available now in Live!

Get 1:1 Help Now