public Preference() { LMB = new ExtendedKey(Keys.NumPad0, false, 82); RMB = new ExtendedKey(Keys.Decimal, false, 83); MMB = new ExtendedKey(Keys.NumPad5, false, 76); WheelUp = new ExtendedKey(Keys.Z, false, 44); WheelDown = new ExtendedKey(Keys.X, false, 45); Left = new ExtendedKey(Keys.NumPad4, false, 75); Right = new ExtendedKey(Keys.NumPad6, false, 77); Up = new ExtendedKey(Keys.NumPad8, false, 72); Down = new ExtendedKey(Keys.NumPad2, false, 80); UpLeft = new ExtendedKey(Keys.NumPad7, false, 71); UpRight = new ExtendedKey(Keys.NumPad9, false, 73); DownLeft = new ExtendedKey(Keys.NumPad1, false, 79); DownRight = new ExtendedKey(Keys.NumPad3, false, 81); Activation = new ExtendedKey(Keys.F11, false, 87); DoubleClick = new ExtendedKey(Keys.Add, false, 28); Drag = new ExtendedKey(Keys.Subtract, false, 74); ClickSpeed = 50; DoubleClickDelay = 100; MovementAcceleration = 1; MaxSpeed = 10; WheelAcceleration = 1; MaxWheelSpeed = 100; }
/// <summary> /// The callback for the keyboard hook /// </summary> /// <param name="code">The hook code, if it isn't >= 0, the function shouldn't do anyting</param> /// <param name="wParam">The event type</param> /// <param name="lParam">The keyhook event information</param> /// <returns></returns> public int hookProc(int code, int wParam, ref keyboardHookStruct lParam) { if (code >= 0) { bool extended = (lParam.flags & LLKHF_EXTENDED) == LLKHF_EXTENDED; Console.WriteLine(string.Format("Scan Code: {0} Virtual Key Code: {1} Is Extended: {2} Flag: {3} Extra Info: {4}", lParam.scanCode, lParam.vkCode, extended.ToString(), lParam.flags, lParam.dwExtraInfo)); ExtendedKey key = new ExtendedKey((Keys)lParam.vkCode, extended, lParam.scanCode); if (HookedKeys.Contains(key) || HookForAny) { KeyEventArgsEx kea = new KeyEventArgsEx(key); if ((wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) && (KeyDown != null)) { KeyDown(this, kea); } else if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null)) { KeyUp(this, kea); } if (kea.Handled) { return(1); } } } return(CallNextHookEx(hhook, code, wParam, ref lParam)); }
public KeyEventArgsEx(ExtendedKey key) : base(key.Key) { Key = key; }
public KeyEventArgsEx(Keys key = Keys.None, bool extended = false, int scanCode = 0) : base(key) { Key = new ExtendedKey(key, extended, scanCode); }