AutoHotkey script with Vim (and now also WASD!) bindings to control the mouse with the keyboard
This is my implementation of a hardware mouse, in software. As of 2023 I believe it has full feature parity with an actual mouse, and has been optimized by daily use for several years. Whatever your reasons for trying to drive the mouse with the keys, this is my very best attempt at creating a program to do so, and I hope you find it as pleasant and convenient to use as I do.
Download the script and binary by cloning this repository from GitHub. The command to run is
git clone [email protected]:4strid/mouse-control.autohotkey.git
If that sentence makes no sense to you at all, no worries! Simply download the repository as a zip file, unzip it, and run the included executable mouse-control.exe :>
The benefit to using git is you can keep up to date with git pull. I'm still (periodically)
pushing little updates here and there to make it better and easier to use.
As of the latest release, a precompiled version is shipped with the source code so you don't have to install anything at all. Just double click the .exe and you're gucci golden! (It's the one with a cute little mouse icon) (Well, I think it's cute; I'm not much of an artist, admittedly)
You should run this script from source; never trust binaries you just find lying around on the Internet, even if it's from a trustworthy source like yours truly :^)
To run it you'll need to install AutoHotkey first. Then you should be able to double click the .ahk file to run the script. Pretty easy right?
Luckily it turns out, you can install either version 1.1 or 2.0, as when you try to run mouse-control.ahk in Version 2, it will happily download the old version and run it appropriately.
This program has modes of input, allowing the keys to sometimes drive the mouse, and sometimes drive the keyboard (inspired by the text editor Vim). There's "Insert mode" where the keys behave normally and "Normal mode" intercepting keys to move and control the mouse instead. (These names are lifted from Vim. I'm aware, "Normal" mode isn't very normal at all)
Home or Win Alt n enters Normal mode
Insert or Win Alt i enters Insert mode
hjklmove the mouseHJKLjump to edges of the screenMjump to center of the screenileft clickoright clickpmiddle clickvhold down left click (hitvor any mouse button again to release)zhold down right click (hitzor any mouse button again to release)chold down middle click (hitcor any mouse button again to release)e,0,]scroll downy,9,[scroll upd,}scroll down fasteru,{scroll up fasterY"yank" a window (reposition it) (press i to release)b"back" mouse buttonn"forward" mouse buttonInsert,Win+Alt+ienter Insert mode
You can also use the WASD keys if they're more natural to you than vim movement keys. Switch into
and out of WASD mode with Win Alt r
WASD mode is now the default for Normal mode.
wasdmove the mouseWASDjump to edges of the screenCjump to center the screenrleft clicktright clickymiddle clickescroll downqscroll up
Note that this necessarily unbinds d e and y from their Vim bindings. The rest of the hotkeys
remain unchanged.
Acts like a normal keyboard.
Home and Win Alt n put you in Normal mode.
If you're in persistent Insert mode and just need the mouse keys for a second, you can hold down Capslock to enter Normal "Quick" mode, which has all the same hotkeys as Normal mode and ends when Capslock is released.
To quickly edit some text then return to Normal mode, a "quick" mode is also available for Insert.
Great for typing into an address bar or a form field. Capslock toggles between Normal and quick
Insert mode.
From Normal mode
:enter QI (Quick Insert mode)Capslocktoggle between QI and Normal modefsend f then enter QI (for Vimium hotlinks)^fsend ctrl f then enter QI (commonly "search")^tsend ctrl t then enter QI (new tab in the browser)Deletesend Delete then enter QI (for quick fixes)
From quick Insert mode:
^cexit to Normal modeEntersend Enter then exit to Normal modeCapslocktoggle between Quick Insert and Normal mode
Home enters Normal mode
Insert enters regular (persistent) Insert mode
I am aware of the Numpad Mouse feature included in Windows, and consider this a Massive improvement over the builtin functionality. I'll say that again, for search optimization, This is an alternative to Numpad Mouse with considerably better usability, and additional functionality. It is a faster and more convenient alternative to Numpad Mouse.
"Why doesn't i take me into Insert mode and Escape put me in Normal mode! >:U"
I made i left click. You've got Win Alt i which is a nice and unintrusive variant of i.
We didn't even used to have that when Win Alt was part of Quick modes so there you go.
Escape is too useful a key to bind to anything. It was infuriating to hit Escape and not have
the expected effect so I took it out.
~ Sorry, nerds :^)
"How come I can't make my own keybindings >:I"
I like these ones. You can fork the repo to make your own, or make a pull request if you want to set up managing an ini file :^)
At the top of the file, mouse speed is controlled by two global variables, FORCE and RESISTANCE. FORCE controls acceleration and RESISTANCE causes diminishing returns and implicitly creates a terminal velocity.
Use the uncompiled .ahk script and you can change these to taste.
Bug reports, questions, feature requests, and pull requests are all welcome. Just open an issue on Github. (Or email me ! Don't be shy I'm really nice)