1
votes

Some days ago, my middle mouse button broke, only scrolling works. The problem is that I use this button a lot, which is a reason that he broke, so i searche about some way to "replace" his function, and i discovered about AutoHotKey. I read many documents and articles about how to make things work using him, and i could make work with Shift + Ctrl + Alt + LButton, but is too much keys to press, so i thinked about ' + LButton. Yes, a Quote . It's a key i don't really use too much, and his location is perfect. I tried and searched how to make it work, but i can't find, and the way i knew gives me an "Invalid hotkey" error.

What i need is a script to AutoHotKey, that simulates an Middle Mouse click when i press ' + LButton.

What i tried is:

'LButton::
Send, MButton
return
2

2 Answers

1
votes

One of these will do it

' & LButton::MButton
~' & LButton::MButton

The first one stops your ' key from being functional, and the second one doesn't but with the second one you will always send one ' when you press mouse middle.


If you're using the second version, pay close attention to this (this won't matter with the first version because your ' key will be disabled).

Be sure to release the ' very quickly when using this hotkey. If you hold it long enough for Window's key repeat functionality feature kicking in, you'll exit out of the mouse middle scrolling mode.
So to use it, press (very short hold) ' and at the same time (slightly after) press (or hold) LButton and release '.
Then you can keep holding LButton, if holding is what you wanted to do.

0
votes

You can easily use LButton with any key but the LButton should be pressed first. Keep in mind that the ' is not a control key, so if you put it before the mouse click it would work but it could cause issues. If you choose to use it that way you should test that it doesn't interfere with your work.

So, LButton + ' would be:

; AHKv1
LButton & ':: SendInput % "{MButton}"
; AHKv2
LButton & ':: SendInput "{MButton}"

The way you wanted it with ' + LButton (use a ~ character to prevent blocking the ' key):

; AHKv1
~' & LButton:: SendInput % "{MButton}"
; AHKv2
~' & LButton:: SendInput "{MButton}"

A better/faster way would be to use a Left Click and then a Right Click (keyboard not required):

; AHKv1
LButton & RButton:: SendInput % "{MButton}"
; AHKv2
LButton & RButton:: SendInput "{MButton}"