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

21 comments:

  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  5. 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.

    ReplyDelete
  6. 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

    ReplyDelete
  7. 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

    ReplyDelete
  8. Each key on the ergonomic keyboard is planned so it is in closeness to all the fingers of the client. This limits the requirement for the fingers, hands and the arms to move so these can keep the ergonomic position while composing. logitech mk270 review

    ReplyDelete
  9. Extremely amazing information you had curated on your blog. I am in IT field and this will be helpful for me sure. Thanks for sharing these tricks.
    Cryptocurrency Smart Contract

    ReplyDelete
  10. Great to be here in your article or post, whatever, I figure I ought to likewise buckle down for my own site like I see some great and refreshed working in your site. Linzhi Phoenix

    ReplyDelete
  11. It is very important to have good thoughts in mind to write a beautiful post and your mind seems very clear only then you have written such a beautiful post, this post is worth praising, it will be less than the praise of this post. Best Bridal Makeup Artist Gurgaon

    ReplyDelete
  12. Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us, I too always learn something new from your post.Best IT consulting Company in India

    ReplyDelete
  13. However, it is basically as it is called - a PC mouse with a warming impact to keep a PC client's mouse hand warm. CPS Test

    ReplyDelete
  14. The warmed PC mouse accomplishes more than give warm, infrared hotness to a PC client's mouse hand. The infrared warmed PC mouse is ergonomic. It's a sound expansion to a PC client's work area. minecraft server list

    ReplyDelete
  15. When you are looking for a cheap wireless mouse, you need to know the pros and cons of getting a low cost wireless mouse. Sometimes, paying a little extra might be worth it. Gaming mouse

    ReplyDelete
  16. I'm finding it works wonderfully on a single laptop monitor but when jumping to the second monitor (w/ different resolution) it jumps 2 inches left and half inch down no matter which direction I push. Any ideas or fixes?

    ReplyDelete
  17. Very good topic, similar texts are I do not know if they are as good as your work out. Satta king 786

    ReplyDelete
  18. Zero in on the benefit
    The principal issue you wish to focus on though partaking in the Satta King 786 games is to procure a huge benefit. You should chase after the Satta assortment that includes a high probability of winning. Maybe then your fortunate assortment. There are different Satta games possible. Anyway if you are endeavoring to play each Satta King, you would perhaps not be prepared to dominate any match. Notwithstanding, if you participate in one Satta King 786, the potential outcomes of winning are overstated.

    ReplyDelete
  19. This blog is really useful in providing up-to-date information on the internet, which is highly commendable. custom erp development

    ReplyDelete