/win10-sticky-mouse

Circumvent mouse sticking between monitors in Windows 10.

Primary LanguageAutoHotkeyMIT LicenseMIT

Repository Archived

This repository has been archived in favor of a better solution:

https://github.com/MouseUnSnag/MouseUnSnag/


Windows 10 Sticky Mouse

Helps to circumvent the mouse sticking between multiple monitors in Windows 10.

What this does (and does not) do:

  • This WILL attempt to prevent the mouse from sticking in corners in between monitors.
  • This WILL NOT prevent the mouse from being stuck between monitors when not near the edge (e.g. in the middle of the screen).

See my other Windows 8 and Windows 10 bug fix for the Explorer titlebar context menu.

Installation Instructions

There are two ways to install and set this up to boot with Windows. Once running, you should see the AutoHotkey icon AutoHotkey System Tray Icon running in your system tray in the bottom right corner of your screen.

Simple:

From Source:

If you prefer to be safer and also have the ability to tinker with the code, you can also run from source. This only requires that you already have AutoHotkey installed.

Run at Startup (Optional):

To ensure this works every time you start your computer, you'll need to perform a few extra steps:

  • Press the Windows Key + R to open the "Run" dialog.
  • Type (or paste) the following and click OK. This should open the windows "Startup" folder: shell:startup
  • Right click the downloaded .exe or .ahk file and select "Copy".
  • Right click inside the "Startup" folder and select "Paste shortcut".

Methodology:

The key to this script is to "teleport" the mouse across the sticky boundary that Windows creates, but to ensure we're looking at momentum as well. More importantly we have to ensure we're tracking where the mouse is currently and where it is going before Windows stops it. This is accomplished by hooking into WM_MOUSEMOVE. It apparently helps to also budge the mouse away from the cross axis of movement (e.g. if you're moving from left to right, you need to bump it downward a bit). It seems that the faster you are moving your mouse, the more you must adjust this cross axis. This is done by calculating a main axis movement delta and then applying a slight coefficient to that movement to help get it past that boundary.

Summary of primary components:

  • Hook into WM_MOUSEMOVE to determine desired mouse position prior to Windows 10's (un)helpful correction.
  • "Teleporting" the mouse two times:
    • Invisibly "teleporting" the mouse along over the main axis of movement first (must be on opposite side of boundary), then down to a cross axis "bump" location based on overall speed (the "coefficient").
    • Teleporting back up to the originally desired mouse position indicated by WM_MOUSEMOVE.

Bugs & Feature Requests:

Please submit an issue (check to make sure that your issue doesn't already exist here). If you can write code, pull requests are very welcome!

Known issues:

  • Pointer may stick (or bounce around a small amount) when moving very slowly.
  • When entering a corner, pointer may come back out at lower/higher location.

To Do

  • Still need to complete vertical monitor mouse capturing (copy/abstract code from horizontal teleportation). Just needs testing.

Acknowledgements

Written out of spite by Patrick Nelson (pat@catchyour.com).

  • Inspired by Jonathan Barton's Delphi-based solution, but instead written from scratch in AutoHotkey.
  • Initial MouseProc() function based on Lexikos' code from this forum post.
  • Cursor hiding SystemCursor() function based on lifeweaver's code from this forum post, originally derived from shimanov's post here.