How can I find the state of NumLock, CapsLock and ScrollLock keys in .net ?
+3
A:
Import the WinAPI function GetKeyState
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
and then you can use it like that
bool CapsLock = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;
bool NumLock = (((ushort)GetKeyState(0x90)) & 0xffff) != 0;
bool ScrollLock = (((ushort)GetKeyState(0x91)) & 0xffff) != 0;
EDIT: the above is for framework 1.1, for framework 2.0 + you can use
pablito
2009-02-23 12:02:51
+1
A:
You can find the answer here:
Which was found with the google terms "caps lock status c#"
MrWiggles
2009-02-23 12:03:40
+1
A:
You'll need to use the Win32 API for this.
Take a look here:
MrWiggles beat me to it
Bart S.
2009-02-23 12:03:50