tags:

views:

279

answers:

2

Hi,

I would like to programmatically check the value of, and be able to toggle num-lock. What's the simplest way to do that in C#?

The reason is that I want to verify num-lock is "ON" at program start.

Thanks

+2  A: 

Check How to programmatically turn on the Numlock Key

ArsenMkrt
+2  A: 

You can do this via P/Invoke with GetKeyboardState and keybd_event.

The MSDN page for keybd_event shows exactly how to toggle num-lock, as well as get it's state (in C++).

There are P/Invoke signitures available on pinvoke.net for keybd_event and GetKeyboardState.

Reed Copsey