I recently found the following AutHotkey script for adding a middle click to a two button mouse by pushing the left and right mouse buttons simultaneously:
~LButton & RButton::MouseClick, Middle
~RButton & LButton::MouseClick, Middle
The script is successful in producing a middle click, but because the ~ preserves the native function, it has the unintended consequence of also generating a left or right click. This is rather annoying, since I use it mainly for tabbed browsing, so half the time, when I try to open a link in a new tab, I also open it in the original tab.
I've been trying desperately to tweak it, but have had no success. I tried the suggestion here to omit the tilde and define LButton and RButton separately, but this eliminates the ability to click and drag. Is there any way to keep the native function of each button EXCEPT when the other button is pressed? Or to interrupt the native function when the other button is pressed, so, for example, if I hold down the left button and press the right button, the release of the left button won't be registered as an event?
Alternatively, would it be possible to leave off the tilde and set the exact desired behavior of LButton and RButton in all cases, while preserving the ability to click and drag?
Any help would be greatly appreciated!
Modified Middle Click Simulator
Started by
surlacarte
, Apr 30 2009 12:42 PM
6 replies to this topic
#1
-
Posted 30 April 2009 - 12:42 PM
Try this, does it work?
#Persistent SetBatchLines, -1 Hotkey,LButton,LButton Hotkey,RButton,RButton Return LButton: Hotkey,RButton,MiddleClick MouseGetPos,x,y Loop{ MouseGetPos,xn,yn If (x!=xn or y!=yn){ Click, down break } } KeyWait,LButton Click, up Hotkey,RButton,RButton Return RButton: Hotkey,LButton,MiddleClick MouseGetPos,x,y Loop{ MouseGetPos,xn,yn If (x!=xn or y!=yn){ Click, down right break } } KeyWait,RButton Click, up Right Hotkey,LButton,LButton Return MiddleClick: Click,M Return
#2
-
Posted 30 April 2009 - 01:12 PM
Thanks so much for the response. This almost works, but not quite. Click and drag works great, as does the middle click, but the left and right mouse buttons don't work right. Specifically, when you do a normal click with either button, it doesn't register until you move the mouse.
#3
-
Posted 30 April 2009 - 10:39 PM
If you don't mind having to start the key combo with the right button, try this
Hotkey, $*LButton, off Hotkey, $*LButton Up, off SetMouseDelay, 0 $*RButton:: RightDown = 1 Hotkey, $*LButton, on Hotkey, $*LButton Up, on Keywait, MButton, LDT0.5 ; pressing the LButton within 0.5 seconds of pressing ; the RButton will remap the LButton to MButton until the RButton is released If ErrorLevel { Hotkey, $*LButton, off Hotkey, $*LButton Up, off Click, Right Down If !RightDown Click, Right Up } Else RightDown = 0 return $*RButton Up:: Hotkey, $*LButton, off Hotkey, $*LButton Up, off If GetKeyState("MButton") Click, Middle Up If (!RightDown) = (RightDown := 0) Click, Right Up return $*LButton::MButton
#4
-
Posted 30 April 2009 - 11:48 PM
I don't really mind having to initiate it with the right mouse button, but if it's going to do that and also disable click and drag with the right mouse button (which it does), I might as well just use this script:
Which, now that I mention it, maybe 90% solves my problem. I do use click and drag with the right mouse button, but not often, and I might be willing to sacrifice it. Thanks for inspiring a solution.
Still, if anyone thinks of a solution that doesn't involve disabling click and drag with the right mouse button, let me know.
RButton & LButton::MouseClick, Middle RButton::Send {RButton}
Which, now that I mention it, maybe 90% solves my problem. I do use click and drag with the right mouse button, but not often, and I might be willing to sacrifice it. Thanks for inspiring a solution.
Still, if anyone thinks of a solution that doesn't involve disabling click and drag with the right mouse button, let me know.
#5
-
Posted 01 May 2009 - 12:26 AM
Actually, the script I posted does not block right-mouse clickdrag. You just have to wait half a second for the down event to go through.
#6
-
Posted 01 May 2009 - 03:23 AM