Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Small script to enable the Num Lock key

Posted on 1998-02-12
2
Medium Priority
?
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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 …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses

715 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