MediatedCommunications / WindowsInput

Capture and Simulate Keyboard and Mouse Input
MIT License
115 stars 17 forks source link

Handled key event #28

Open savian-net opened 7 months ago

savian-net commented 7 months ago

I am handling the key chord (CTRL+,) w/o an issue. However, the key chord fires my event and then inserts the comma afterward. Is there a way to handle the keybpoard event so the keyboard knows it is handled?

var ImportStylesListener = new KeyChordEventSource(keyboard, new ChordClick(KeyCode.Control, KeyCode.Oemcomma)); ImportStylesListener.Triggered += (x, y) => ImportStylesListener_Triggered(keyboard, x, y); ImportStylesListener.Reset_On_Parent_EnabledChanged = false; ImportStylesListener.Enabled = true;

private void ImportStylesListener_Triggered(IKeyboardEventSource Keyboard, object sender, KeyChordEventArgs e) { if (Globals.ThisAddIn.Application.Documents.Count == 0) { return; } Log.Info($"Command executed using shortcut: Import Styles (CTRL+,)"); using (Keyboard.Suspend()) { e.Input.Next_Hook_Enabled = false; Common.WCRibbon.ExecuteImportStylesForm(); } //WindowsInput.Simulate.Events().Click(KeyCode.Control).Invoke(); }