Detect if NumLock is turned off and always turn it on

What is the detection method if NumLock is turned off and how to always turn it on when my VB APP is running?

EDIT: My application is an application running on a dedicated computer with an external numpad device.

another option: TAKE the NUMPAD ARROW BUTTONS (etc.) and convert them to NUMBERS on the fly, is this possible? (for example, ignore the situation with disabling numlock and behave when numlock is enabled)

0
source share
4 answers

I'm not sure how you do it specifically in vb.net (quick google search http://support.microsoft.com/kb/177674 ), but generally speaking, changing machine parameters like this is disapproving: users are used to their individual preference for the key state of numlock (or caplock - or any other) ... and you redefine it.

It will really annoy me.

However, in circumstances where your application only works (for example, POS software, medical office management software, etc.), this may be normal.

+3
source

Physically delete the NUMPAD key?

+2
source
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Const KEYEVENTF_KEYUP = &H2 Const VK_NUMLOCK = &H90 Const KEYEVENTF_EXTENDEDKEY = &H1 Declare Function GetKeyState Lib "user32" Alias "GetKeyState" (ByVal ByValnVirtKey As Integer) As Short Private Sub numlockON() keybd_event(VK_NUMLOCK, 0, 0, 0) ' Press NUMLOCK key down keybd_event(VK_NUMLOCK, 0, KEYEVENTF_KEYUP, 0) ' Release it End Sub If Not GetKeyState(VK_NUMLOCK) Then numlockON() 
+1
source
 Public Const VK_NUMLOCK = &H90 Declare Function GetKeyState Lib "user32" Alias "GetKeyState" _ (ByVal ByValnVirtKey As Integer) As Short Private Sub me_keyDown(ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyCode = Keys.NumLock And Not NLKey Then If Not GetKeyState(VK_NUMLOCK) Then e.Handled = True NumlOn.Start() Exit Sub End If End If End sub Private Sub NumlOn_Tick(sender As Object, e As EventArgs) Handles NumlOn.Tick NLKey = True If Not GetKeyState(VK_NUMLOCK) Then numlockON() Application.DoEvents() NumlOn.Stop() NLKey = False End Sub 
0
source

All Articles