Solved

Small script to enable the Num Lock key

Posted on 1998-02-12
2
372 Views
Last Modified: 2012-05-07
How to use a small QB/VB script to enable the Num Lock key?
(Preferer use QB command if you know.)

Thanks.
0
Comment
Question by:st
  • 2
2 Comments
 
LVL 7

Accepted Solution

by:
kamall earned 30 total points
ID: 1457005
The KeyState custom control that is shipped with VB can do this job. It can turn ON and OFF the NumLock, CapsLock, ScrollLock, and the INS keys.
I had some code for QB but I couldn't find it at this moment. I will try to search for it.
Regards
0
 
LVL 7

Expert Comment

by:kamall
ID: 1457006
Here is some other code for manipulating the CapsLock, NumLock, etc. without using the KeyState control (in VB):

Functin GetCapslock() As Boolean
'     ' Return or set the Capslock toggle.
GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
End Function

Fuction GetNumlock() As Boolean
'     ' Return or set the Numlock toggle.
GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
End Function


Function GetScrollLock() As Boolean

       '     ' Return or set the ScrollLock toggle.
       GetScrollLock = CBool(GetKeyState(vbKeyScrollLock) And 1)
End Function


Sub SetCapslock(Value As Boolean)

       '     ' Return or set the Capslock toggle.
       Call SetKeyState(vbKeyCapital, Value)
End Sub


Sub SetNumlock(Value As Boolean)

       '     ' Return or set the Numlock toggle.
       Call SetKeyState(vbKeyNumlock, Value)
End Sub

Set SetScrollLock(Value As Boolean)
'     ' Return or set the ScrollLock toggle.
Call SetKeyState(vbKeyScrollLock, Value)
End Sub


Private Sub SetKeyState(intKey As Integer, fTurnOn As Boolean)

       '     ' Retrieve the keyboard state, set the particular
       '     ' key in which you're interested, and then set
       '     ' the entire keyboard state back the way it
       '     ' was, with the one key altered.
       Dim abytBuffer(0 To 255) As Byte
       GetKeyboardState abytBuffer(0)
       abytBuffer(intKey) = CByte(Abs(fTurnOn))
       SetKeyboardState abytBuffer(0)
End Sub


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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

785 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