private static void OnKeyboardAction(object sender, KeyboardActionEventArgs e) { Keys vkCode = (Keys)e.Data.VirtualKeyCode; //more research needed: if (vkCode == Keys.LControlKey || vkCode == Keys.RControlKey) { vkCode = Keys.ControlKey; } if (vkCode == Keys.LShiftKey || vkCode == Keys.RShiftKey) { vkCode = Keys.ShiftKey; } if (vkCode == Keys.LMenu || vkCode == Keys.RMenu) { vkCode = Keys.Menu; } switch (e.Action) { case KeyboardAction.KeyDown: case KeyboardAction.SysKeyDown: lock (MacroLock) { if (!CurrentMacro.Contains((uint)vkCode)) { CurrentMacro.Add((uint)vkCode); } foreach (MacroEntry entry in Macros.Values.Where(x => x.Enabled)) { if (entry.Binding.Equals(CurrentMacro)) { entry.Function.Execute(); e.IsCancelled = true; break; } } //wtf Console.WriteLine($"Current macro: {String.Join(",", CurrentMacro)}"); // } break; case KeyboardAction.KeyUp: case KeyboardAction.SysKeyUp: lock (MacroLock) if (CurrentMacro.Count > 0) { if (CurrentMacro[0] == (uint)vkCode) { CurrentMacro.Clear(); } else if (CurrentMacro.Last() == (uint)vkCode) { CurrentMacro.RemoveAt(CurrentMacro.Count - 1); } } break; } }
internal void Outdent(object sender, KeyboardActionEventArgs args) { //VVV //Outdent(); string outdentText = "\t"; if (sender is EditViewControl viewControl && viewControl.TabsToSpaces) { outdentText = new string(' ', viewControl.TabSize); } Outdent(outdentText); }
private IntPtr LLKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam) { KeyboardActionEventArgs eventArgs = new KeyboardActionEventArgs { IsCancelled = false }; if (nCode >= 0) { eventArgs.Action = (KeyboardAction)wParam.ToInt32(); eventArgs.Data = Marshal.PtrToStructure <KeyboardEventData>(lParam); try { KeyboardAction?.Invoke(this, eventArgs); } catch { } } return(eventArgs.IsCancelled ? (IntPtr)1 : CallNextHookEx(m_hhook, nCode, wParam, lParam)); }
void KeyboardView_Action(object sender, KeyboardActionEventArgs e) { switch (e.Action) { case KeyboardAction.Space: CurrentInputConnection.CommitText(new Java.Lang.String(" "), 1); break; case KeyboardAction.Delete: var wordToDelete = CurrentInputConnection .GetTextBeforeCursor(25, GetTextFlags.None) .Split(' ').LastOrDefault(str => !string.IsNullOrEmpty(str)); if (!string.IsNullOrEmpty(wordToDelete)) { CurrentInputConnection.DeleteSurroundingText(wordToDelete.Length, 0); } break; } }