private void MainForm_Load(object sender, EventArgs e) { if (HotKeyRegister.Register(this.Handle, (int)Keys.OemQuestion) == false) { Console.WriteLine("Error to register hotkey."); } }
protected override void WndProc(ref Message m) { base.WndProc(ref m); if (HotKeyRegister.IsHotkeyMessage(m.Msg)) { if (HotKeyRegister.IsHotkeyId((int)m.WParam)) { ShowForm(); } } }
private void InitHotKey() { for (int i = 0; i < this.Name.Length; i++) { hotchar = (uint)this.Name.ToUpper()[i]; if (hotchar == ' ') { hotchar = 0; continue; } bool b = HotKeyRegister.GetHotKeyRegister().RegisterHotKey(Util.ModifierKeys.MOD_WIN, (Keys)hotchar, this); if (b) { break; } } if (hotchar != 0) { labelDescription.Text = labelDescription.Text + " ( Shortcut Win+" + (char)hotchar + " )"; } else { labelDescription.Text = labelDescription.Text + " ( No Shortcut registered. )"; } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { HotKeyRegister.Unregister(this.Handle); }