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

x
?
Solved

Small script to enable the Num Lock key

Posted on 1998-02-12
2
Medium Priority
?
378 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 60 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

971 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