This is basically a simple question.
I want to update the label dynamically when I press the capslock and numlock keys while the main form is open in the WinForm application on the .net
platform. How can I do this?
This is basically a simple question.
I want to update the label dynamically when I press the capslock and numlock keys while the main form is open in the WinForm application on the .net
platform. How can I do this?
You have to listen for keypress callbacks like that
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
{
Keys k = (Keys)Marshal.ReadInt32(lParam);
if (k == Keys.Capital)
{
label1.Text = "Heureka";
}
}
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}