473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Numlock Key

Hi

I saw a post about numlock but I can't not read it.

I would like to check the state of the numlock key
and if it's not active, set its status on active.
How can I accomplish that in vb ?

Stan
Nov 20 '05 #1
5 1938
Hi,

API Declare
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Integer) As
Integer

Const VK_CONTROL = 11

Const VK_NUMLOCK = 144

Const VK_CAPLOCK = 20

How to use

Dim strNum As String

If GetKeyState(VK_NUMLOCK) Then

strNum = "Num"

Else

strNum = ""

End If

Ken

--------------------

"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:uw*************@TK2MSFTNGP12.phx.gbl...
Hi

I saw a post about numlock but I can't not read it.

I would like to check the state of the numlock key
and if it's not active, set its status on active.
How can I accomplish that in vb ?

Stan

Nov 20 '05 #2
* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit:
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Integer) As
Integer


Doesn't 'GetKeyState' return a 'Short' ('Int16')?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Hi

I thank you for your reply.. :-)
and how can I force the numlock ?
Something like SetKeyState ?

Stan

"Ken Tucker [MVP]" <vb***@bellsouth.net> a écrit dans le message de
news:OC**************@TK2MSFTNGP11.phx.gbl...
Hi,
Yes it is a short. My bad.

Ken
--------------
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ue**************@TK2MSFTNGP10.phx.gbl...
* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit:
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Integer) As Integer


Doesn't 'GetKeyState' return a 'Short' ('Int16')?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


Nov 20 '05 #4
Hi,

Sorry I dont have an example but look at sendinput and keybd_event
api functions.

http://msdn.microsoft.com/library/de.../sendinput.asp

http://msdn.microsoft.com/library/de...eybd_event.asp
Ken
-------------------
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...
Hi

I thank you for your reply.. :-)
and how can I force the numlock ?
Something like SetKeyState ?

Stan

"Ken Tucker [MVP]" <vb***@bellsouth.net> a écrit dans le message de
news:OC**************@TK2MSFTNGP11.phx.gbl...
Hi,
Yes it is a short. My bad.

Ken
--------------
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ue**************@TK2MSFTNGP10.phx.gbl...
>* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit:
>> Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Integer) As >> Integer
>
> Doesn't 'GetKeyState' return a 'Short' ('Int16')?
>
> --
> Herfried K. Wagner [MVP]
> <http://www.mvps.org/dotnet>



Nov 20 '05 #5
Ken,

* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit:
Sorry I dont have an example but look at sendinput and keybd_event
api functions.

http://msdn.microsoft.com/library/de.../sendinput.asp

http://msdn.microsoft.com/library/de...eybd_event.asp


Maybe somebody wants to translate this VB6 sample:

<http://www.activevb.de/tipps/vb6tipps/tipp0181.html>

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: George | last post by:
Every time I used the Sendkeys command in my application the "Numlock" turned off and I couldn't use the keypad to hit numbers...... The old code was: Private Sub Command1_Click() SendKeys...
5
by: James Kirkup | last post by:
Hello, Does anyone know in code how to turn the NumLock key on in C#? with regards James *** Sent via Developersdex http://www.developersdex.com ***
2
by: Chris | last post by:
can anyone out there tell me how do u check the state of these keys in vb.net? or is there any components in the .NET Framework that supports doing so? any help is appreciated. Thanks.
2
by: Woody Splawn | last post by:
Could someone tell me what code I run to determine if the user's numlock is on? Is there code I can run to set the numlock to on?
1
by: nTn | last post by:
I'd like show in my status bar, status of NumLock, CapsLock and ScrollLock. How I do? Thx
10
by: lgbjr | last post by:
Hi All, In VB.Net how do I determine if CapsLock is on/off (same for NumLock) and whether the input mode is set to Insert or Overwrite (Insert Key). I just added a status bar to my app, and I...
0
by: =?Utf-8?B?Q29tcHV0ZXJfRW5naW5lZXJfU3R1ZGVudA==?= | last post by:
I'm locking for an C# equivalent to the VBS code On Error Resume Next Set objWord = CreateObject("Word.Application", "" & txtPCName.Value & "") strCapsLock = objWord.CapsLock strNumLock =...
0
by: Yusuf Incekara | last post by:
I 've assigned a shortcut key for CTRL+SHIFT+1 key in my application. I can handle these keys in Form's keydown event. private void Form1_Load(object sender, EventArgs e) { this.KeyPreview =...
3
by: Z.K. | last post by:
I am trying to detect if the Numlock is pressed. I can do it okay with the CapsLock or the ScrLk, but not with NumLock. The code for all three checks is exactly the same, but for some reason...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.