It is easy to register A method similar to ctr + alt + shit + A + Z. Set the 3rd parameters of RegisterHotKey to KeyModifiers. Alt | KeyModifiers. Control | KeyModifiers. Shift,
Set the 4th parameters to Keys. B | Keys. Z.
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using System. Runtime. InteropServices;
Using System. Threading;
Namespace rgHotKeys
{
Public enum KeyModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}
Public partial class Form1: Form
{
[DllImport ("user32.dll", SetLastError = true)]
Public static extern bool RegisterHotKey (IntPtr hwnd, int id, int fsModifiers, int vk );
[DllImport ("user32.dll", SetLastError = true)]
Public static extern bool UnregisterHotKey (
IntPtr hWnd, // handle to window
Int id // hot key identifier
);
Private int id;
Public Form1 ()
{
InitializeComponent ();
}
Private void Form1_Load (object sender, EventArgs e)
{
Id = Thread. CurrentThread. GetHashCode ();
RegisterHotKey (this. Handle, id, (int) KeyModifiers. Alt, (int) Keys. F12 );
}
Protected override void WndProc (ref Message m)
{
Const int WM_HOTKEY = 0x0312;
Switch (m. Msg)
{
Case WM_HOTKEY:
If (id = (int) m. WParam)
{
System. Windows. Forms. MessageBox. Show ("Hello! ");
}
Break;
}
Base. WndProc (ref m );
}
Private void form=formclosed (object sender, FormClosedEventArgs e)
{
UnregisterHotKey (this. Handle, 10001 );
}
}
}