Solved

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

Posted on 2001-09-11
5
470 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 50

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

776 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