[DllImport("user32.dll", SetLastError = true)]
public static extern bool RegisterHotKey(
IntPtr hWnd,
int id,
KeyModifiers fsModifiers,
Keys vk
);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterHotKey(
IntPtr hWnd,
int id);
const int F11 = 0x0312;
protected override void WndProc(ref Message message)
{
if (message.Msg == F11)
{
timer1.Enabled = true;
}
base.WndProc(ref message);
}
public enum KeyModifiers //enum to call 3rd parameter of RegisterHotKey easily
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}
const int F11 = 0x0312;

[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetAsyncKeyState(int vkey);
