Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Num-lock Question

Num-lock Question

Num-lock Question

I have the following code to enable the Num-lock Key,
set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{NUMLOCK}"

but I need it to be able to verify the state before,

if Num-lock key is active
   dont change state
is Num-lock key is inactive
   Activate Numlock key.
Any advice is well appreciated.


RE: Num-lock Question

Hello ronnetp,

This is an utterly unrewarding little task to do with vbs. It is so unreliable. Not to mention a routine to check it first, even the sendkey by itself seems very unreliable to toggle the light on the keyboard. Do your experience convince you that the result being consistent?

To check the numlock state, one of the trick is to use the winword as a vehicle to do it for you.

Set objWord=CreateObject("Word.Application")
Set objWord=Nothing

Remember to quit the word by .Quit otherwise the silent process would build up in number and bloat your box by repetitive testing.

Warning: This is very unreliable. If you go to test it, you know what I mean. It is as unreliable as the SendKeys, no more no less.

So, both little tasks, I am not enthusiastic about.

regards - tsuji

RE: Num-lock Question

Thanks, tsuji

For sharing, another problem besides not been reliable
is that I have workstations that dont have Word Installed.

I have not found a way of doing this!!!

RE: Num-lock Question

Sadly, the most reliable way of doing this is with the SetKeyState API call. Unfortunately you cannot make direct API calls with VBScript

RE: Num-lock Question

I can use other way, for me it does not have to be
vbscript, I just wanted to make something without
needing to compile.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close