Skip to content

Add ctrl-to-cross-monitors v0.1#3569

Open
manudesir wants to merge 2 commits intoramensoftware:mainfrom
manudesir:add-ctrl-to-cross-monitors
Open

Add ctrl-to-cross-monitors v0.1#3569
manudesir wants to merge 2 commits intoramensoftware:mainfrom
manudesir:add-ctrl-to-cross-monitors

Conversation

@manudesir
Copy link

Summary:
This mod prevents the mouse cursor from moving to another monitor unless Ctrl is held while moving the mouse.

Tested:

  • manual testing on a multi-monitor setup
  • movement within a monitor is unaffected
  • crossing to another monitor is blocked when Ctrl is not held
  • crossing is allowed when Ctrl is held

Known limitation

When the Windhawk app window is focused, the cursor restriction does not work. But it works the rest of the time

Author GitHub:
https://github.com/manudesir

License:
MIT

@manudesir manudesir force-pushed the add-ctrl-to-cross-monitors branch from e442ddc to ef15ad3 Compare March 17, 2026 08:50
// ==WindhawkModSettings==
/*
- enabled: true
$name: Enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the value in having this option compared to disabling the mod?

ResetCursorState();
}

// Everything below is Windhawk tool boilerplate; the cursor behavior lives above.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be more convenient to maintain if you could keep the snippet below identical to the code in the wiki page:
https://github.com/ramensoftware/windhawk/wiki/Mods-as-tools:-Running-mods-in-a-dedicated-process
Thanks.

Comment on lines +220 to +221
while (GetMessageW(&msg, nullptr, 0, 0) > 0) {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the standard message loop implementation:

Suggested change
while (GetMessageW(&msg, nullptr, 0, 0) > 0) {
}
while (GetMessageW(&msg, nullptr, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessageW(&msg);
}


if (crossedMonitor && !IsCtrlHeld()) {
LogMonitorCrossing(true, g_cursorState.lastPoint, currentPoint);
ForceCursorTo(g_cursorState.lastPoint);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're preventing the move event, is it necessary to also set the cursor pos? If not, you can probably also remove forcedPoint and ignoreForcedPoint.

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.

2 participants