private WindowsHelper.Hotkey GetHotkeyFromControls() { WindowsHelper.KeyModifier Modifiers = WindowsHelper.KeyModifier.None; if (chk_Alt.Checked) { Modifiers += (int)WindowsHelper.KeyModifier.Alt; } if (chk_Control.Checked) { Modifiers += (int)WindowsHelper.KeyModifier.Control; } if (chk_Shift.Checked) { Modifiers += (int)WindowsHelper.KeyModifier.Shift; } Keys key = (Keys)combo_Character.SelectedItem; return(new WindowsHelper.Hotkey(Modifiers, key)); }
// Handle global hotkeys protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == 0x0312) { Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF); WindowsHelper.KeyModifier modifier = (WindowsHelper.KeyModifier)((int)m.LParam & 0xFFFF); int id = m.WParam.ToInt32(); PasteAction matchedAction = new PasteAction(); foreach (PasteAction action in Global.Actions) { if (action.HotKeyRegistrationID == id) { matchedAction = action; } } if (string.IsNullOrEmpty(matchedAction.Name)) { MessageBox.Show("No action is matched to that hotkey"); this.Close(); return; } if (matchedAction.ID == "{00000000-0000-0000-0000-000000000000}") { openActionPicker(); } else if (matchedAction.ID == "{00000000-0000-0000-0000-000000000001}") { WindowsHelper.SetForegroundWindow(this.Handle); WindowsHelper.ShowWindowAsync(this.Handle, 1); } else { matchedAction.Paste(Global.LastApplications[0].WindowHandle, Global.LastApplications[0].LastActiveWindowMode); } } }