private void StartTracking() { _hook = (int x, IntPtr wParam, IntPtr lParam) => { crosshairAxisX.Top = Cursor.Position.Y - Config.DesktopTop; crosshairAxisY.Left = Cursor.Position.X - Config.DesktopLeft; return(WindowsApi.CallNextHookEx(x, WindowsApi.WH_MOUSE_LL, wParam, lParam)); }; WindowsApi.SetGlobalMouseHook(_hook); }
private void RegisterHotkeys() { WindowsApi.KeyModifiers modifiers = WindowsApi.KeyModifiers.MOD_CONTROL | WindowsApi.KeyModifiers.MOD_NOREPEAT; _hotkeyIdFullGrid = this.Handle.ToInt32() ^ (int)modifiers ^ (int)Keys.D1; _hotkeyIdCrosshair = this.Handle.ToInt32() ^ (int)modifiers ^ (int)Keys.D2; WindowsApi.RegisterHotKey(this.Handle, _hotkeyIdFullGrid, modifiers, Keys.D1); WindowsApi.RegisterHotKey(this.Handle, _hotkeyIdCrosshair, modifiers, Keys.D2); }
protected override void SetVisibleCore(bool value) { if (value) { StartTracking(); } else { WindowsApi.UnhookMouseHook(); } base.SetVisibleCore(value); }
private void UnregisterHotkeys() { WindowsApi.UnregisterHotKey(this.Handle, _hotkeyIdFullGrid); WindowsApi.UnregisterHotKey(this.Handle, _hotkeyIdCrosshair); }
public GridWindow() { InitializeComponent(); WindowsApi.SetAsOverlay(this); }
public CrosshairWindow() { InitializeComponent(); WindowsApi.SetAsOverlay(this); DrawCrosshair(); }