Hi
How can I know if NumLock is On Or Off
And how can change the status of the NumLock
From my program to On Or Off
Please send me a small example
The code:
SendKeys.Send("{NUMLOCK}")
not work always !!!
Have a nice day
Printable View
Hi
How can I know if NumLock is On Or Off
And how can change the status of the NumLock
From my program to On Or Off
Please send me a small example
The code:
SendKeys.Send("{NUMLOCK}")
not work always !!!
Have a nice day
The reason setting NUM LOCK doesn't always work is that it is only temporarily set until SendKeys yields to another process.
You can use an API to permanently set NUM LOCK. MSDN has an article on this. Search for "HOWTO: Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys" and PSS ID Number: 177674.
To get the state of the NumLock key try this:
VB Code:
Public Declare Auto Function GetKeyState Lib "user32" _ (ByVal nVirtKey As Integer) As Short Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = GetKeyState(144) End Sub
Hi,
Ok, very small and nice
Now how can change the status of the NumLock
From my program to On Or Off
Doesn't the first of my previous two replies give you enough information for this?
Hi,
I download the:
"HOWTO: Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys"
It is for vb6
I try it in vb.net and i not able to convert it to vb.net
if you want to see it, i uploade it
Thanks
Hi,
Ok, I got it
Declare Function GetKeyboardState Lib "user32" _
Alias "GetKeyboardState" (ByVal pbKeyState() As Byte) As Long
Private Sub Button1_Click...
Dim state(256) As Byte
GetKeyboardState(state)
If state(Keys.NumLock) = 1 Then
MsgBox("true") 'Only for test
SendKeys.Send("{NUMLOCK}")
' My code
SendKeys.Send("{NUMLOCK}")
Else
MsgBox("false") 'Only for test
' My code
End If
End Sub