Tuesday, June 27, 2017

AutoHotKey - Control Your Mouse With Your Keyboard

     A month ago I bought a 40% keyboard. Some people might be wondering what a 40% keyboard is, it is just what you would think it is, it is 40% of the size of the standard 105 key layout. All the keys that have been removed are now stored in programmable layers. so for instance to make an exclamation mark I have to hold down, Fn1 + right shift + Capslock, this might seem insane but it is actually very intuitive after a week or so and now that I have fully adjusted I can hit any key without moving my fingers from the home row. Good-bye wrist pain!

Vortex Core

To be completely honest I did not think I would like using a 40% keyboard, especially as a daily driver. But after a week or two I found myself enjoying typing like seriously, typing is now fun and enjoyable.

Vortex Core

Alright now that we have gotten that out of the way, the point of this post is to share an AutoHotKey script that I have been running which allows me to control my mouse without actually having a mouse!

This script was developed using the AutoHotKey programming language and was aimed towards a 40% keyboard but with some slight modifications, it can work on any keyboard. Please review the comments and adjust accordingly for a full-size keyboard.

Here's the script in all its glory!
; MouseControl.ahk
; Hold down Control and then use the arrow keys to move the mouse cursor around the screen
; Updated on June 22nd, 2017 by Matt Kerfoot.
; Updated on June 27nd, 2017
; www.TheOvernightAdmin.com

#Persistent ; Keeps the script permanently running (that is, until the user closes it or ExitApp is encountered)

SetDefaultMouseSpeed, 1 ; Mouse speed, kind of like reaction time I do believe
distance = 30        ; how far the mouse moves each turn of the timer
multiplier = 1.16    ; how much farther (exponentially) the mouse moves in a direction the longer you hold that direction down
CFKM = 30            ; how often to run the timer
SetTimer, CheckForKeyMouse, %CFKM% ; Controls mouse movement speed
return ; end of mouse control movement control function

CheckForKeyMouse: ; Beginning of Function statement
if not GetKeyState("Control") ; Requires Ctrl to be held down
return ; required otherwise down control will not work

GetKeyState("Down")  ? (d*=multiplier) : (d:=1) ; While holding down shift, the down arrow will allow you to move the mouse to the down
GetKeyState("Up")    ? (u*=multiplier) : (u:=1) ; While holding down shift, the up arrow will allow you to move the mouse to the up
GetKeyState("Right") ? (r*=multiplier) : (r:=1) ; While holding down shift, the right arrow will allow you to move the mouse to the down
GetKeyState("Left")  ? (l*=multiplier) : (l:=1) ; While holding down shift, the left arrow will allow you to move the mouse to the left

y := (d-u) * distance ; math to tell how far to move the cursor
x := (r-l) * distance ; more math to define how far the cursor moves per key press

MouseMove, x, y, , R ; Initiates the action of moving the mouse
^PgDn::Click,      right ; Sets Ctrl + PgDn to perform a right click
^BackSpace::Click, right ; Sets Ctrl + backspace to perform a left click
^PgUp::Click,      left  ; Sets Ctrl + PgUp to perform a left click
^Esc::Click,       left  ; Sets Ctrl + Escape to perform a left click
^r::Reload  ; Assign Ctrl-R as a hotkey to restart the script.
Return ; End of Function statement

 I hope you enjoy it as much as I do! Any questions, just ask!

-Matt Kerfoot


  1. This is extremely fascinating substance! I have completely delighted in perusing your focuses and have reached the conclusion that you are right about a hefty portion of them. You are extraordinary.  Gear Hint

  2. Extraordinary blog. I took pleasure in scrutinizing your articles. This is extremely a marvelous scrutinized for me. I have bookmarked it and I am suspecting examining new articles. Continue doing magnificent! Sky Naite travel

  3. Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information. ghee butter private label

  4. Hi, I find reading this article a joy. It is extremely helpful and interesting and very much looking forward to reading more of your work. best massage device

  5. Incredible tips and straightforward. This will be exceptionally helpful for me when I get an opportunity to begin my blog. Agen QQ Online

  6. In fact, if you cannot completely learn keyboard online, there are also a lot of software that will help you make your learning fast and easy. Of course, in this age where people want fast, kinesis keyboard easy and convenient, software and computer programs are preferred.

  7. Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.. video

  8. Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited f or so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. slot joker123

  9. Excellent post. I was reviewing this blog continuously, and I am impressed! Extremely helpful information especially this page. Thank you and good luck.pokergalaxy