Skip to content

feat: let shortcuts use the middle and side mouse buttons and the scroll wheel - #41

Merged
CodySimonds65 merged 1 commit into
mainfrom
feature/mouse-shortcuts
Oct 6, 2026
Merged

CodySimonds65 merged 1 commit into
mainfrom
feature/mouse-shortcuts

Conversation

@CodySimonds65

Copy link
Copy Markdown
Owner

Shortcuts can now be bound to mouse input as well as keys, in Settings → Shortcuts and in the Timer plugin's settings.

What you can record

  • Middle click, Mouse 4, Mouse 5, scroll up and scroll down.
  • Each with or without Ctrl, Alt or Shift, for example Shift+Scroll down or Ctrl+Middle click.
  • Left and right click are not recordable: they would fire on every click, and they are needed to operate the dialog while recording.

How they behave

  • Observed, not taken. Windows cannot register a mouse button as a hotkey, so mouse shortcuts go through raw input like plain keys do. The click or scroll still reaches the game.
  • Only while FourFold is in front. A mouse shortcut fires only when a FourFold window is the foreground window, so scrolling in another app does not switch tabs. This differs from plain keys, which still fire everywhere.
  • Modifiers must match exactly for a mouse shortcut bound with them. One bound without modifiers still fires with Ctrl, Alt or Shift held, unless that exact combination is another shortcut. This is the existing plain-key rule.
  • One fire per wheel notch. Smooth-scrolling wheels report a notch in fractions; these add up to a full notch before firing, and turning the wheel back starts over.
  • No cost when unused. The mouse is registered for raw input only while at least one mouse shortcut is bound, so nobody else pays for a message per mouse movement.

How it is stored

Mouse inputs reuse the existing shortcut fields. The buttons use their Windows virtual-key codes (0x04 to 0x06) and the wheel directions sit just past the keyboard range (0x100, 0x101), so the settings format, duplicate detection and the registration code need no structural change. An older version reading such a file treats the value as invalid and falls back to that shortcut's default.

Changes

  • GlobalHotkeyChord: accepts the five mouse inputs. IsPlainKey becomes IsObserved, which is also true for a mouse input with modifiers.
  • PlainKeyShortcutMatcher: an exact match fires when it is an observed shortcut; otherwise a shortcut bound without modifiers fires as before.
  • RawKeyboardListener is renamed RawInputListener. It now also decodes raw mouse buttons and the wheel, switches the mouse on and off on request, and reports each input through a callback.
  • MainWindow: routes mouse inputs through the same matcher, with the foreground check.
  • ShortcutCapture, ShortcutText, SettingsDialog, TimerSettingsPage: record and display the new inputs.
  • README and the Shortcuts tab explain the mouse behaviour.

F5 stays reserved for reloading a game panel; the key rules are unchanged.

Tests

  • Which inputs are valid and observed: the five mouse inputs are, with or without modifiers; left click, right click and F5 are not.
  • Matching: a mouse shortcut with modifiers needs exactly those modifiers; one without still fires with a modifier held unless that combination is bound elsewhere.
  • Decoding raw mouse events: button presses and releases, several changes in one event, a press and release per wheel notch, smooth-wheel fractions, and nothing for left click, right click, sideways scroll or movement.

dotnet test src/FourFoldAccountManager.Core.Tests: 323 passed. dotnet test src/FourFoldAccountManager.Desktop.Tests: 37 passed.

Also checked with a one-off probe that injected a real wheel notch each way into a window using the listener: nothing arrived with the mouse switched off, and both directions decoded correctly once it was on. Recording and live firing over a game panel were then tried by hand in a build of this branch.

Worth knowing

  • Ctrl+Scroll as a shortcut also zooms the game panel, because the scroll still reaches the browser view. Alt or Shift with the wheel avoids that.
  • Recording in the Timer settings needs the pointer over that settings page when you click or scroll.
  • Sideways scrolling is not recordable.

Merging publishes a client release, since this touches src/.

…oll wheel

Middle click, Mouse 4, Mouse 5, scroll up and scroll down can be recorded for any shortcut, with or without Ctrl, Alt or Shift. Windows cannot register a mouse button as a hotkey, so these are observed through raw input like plain keys: the click or scroll still reaches the game. They only act while a FourFold window is in front, and the mouse is only listened to while a mouse shortcut is bound. Left and right click stay unavailable.
@CodySimonds65
CodySimonds65 merged commit 81e3b6e into main Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant