public void Handle(InputArgs e) { if (_captureAll) { e.Capture = true; if (e.Input == Env.Config.CloseKey) { _captureAll = false; } } else if (e.Input == Env.Config.ToggleHookKey) { if (e.Down && !_toggleKeyIsDown) { var enabled = _enabled; Reset(); _enabled = !enabled; } else if (!e.Down) { _toggleKeyIsDown = false; } } else if (_enabled) { if (_simulatedInput != null && e.Up && e.Input == _simulatedInput.Item1) { ReleaseSimulatedInput(); e.Capture = true; } _targetHook.Handle(e); } }
public void Handle(InputArgs e) { _targetHook.Handle(e); if (!e.Capture) { Env.CreateInjector().Add(e.Input, e.Down).Run(); } }
private IntPtr HookProcedure(int code, IntPtr wParam, IntPtr lParam) { var captured = false; try { if (code >= 0 && TryReadMessage((WindowMessage)wParam, lParam, out var e)) { if (Env.Config.CaptureLmb && e.Input == Input.Lmb) { captured = true; } _targetHook.Handle(e); captured = e.Capture; } } catch (Exception ex) // This is the last place to handle any exceptions thrown during the hook procedure. { Helper.AwaitTask(Helper.HandleExceptionAsync(ex)); } return(captured ? new IntPtr(-1) : NativeMethods.CallNextHookEx(IntPtr.Zero, code, wParam, lParam)); }
public IInjector Add(Input input, bool down) { _actions.Add(() => { _targetHook.Handle(new InputArgs(input, down)); }); return(this); }