Reputation: 383
I have this script:
~LButton & RButton::
Click Middle
Return
Supposedly when I press LButton
and RButton
together, they'll work as the MButton
. This does work but it sends the LButton
as well. If I remove the ~
from the hotkey prefix, LButton
stops working altogether.
I've tried various ways to try and make it work.
This does not work:
#If GetKeyState("LButton", "P")
RButton::
Click Middle
Return
This doesn't work either:
middleclicktrigger := False
LButton & RButton::
middleclicktrigger := True
Click Middle
middleclicktrigger := False
Return
~LButton::
If (middleclicktrigger) {
BlockInput, Mouse
}
Return
This supposedly works but I encountered a problem where I cannot hold and drag the LButton
with normal usage. It works fine with simple left clicking but I need it to work as a normal left mouse button when it's not being used along with the right mouse button in a hotkey combination:
middleclicktrigger := False
LButton & RButton::
middleclicktrigger := True
Click Middle
middleclicktrigger := False
Return
LButton::
IF (!middleclicktrigger) {
Click down
}
Return
LButton up::
IF (!middleclicktrigger) {
Click up
}
Return
Upvotes: 4
Views: 1150
Reputation: 11
Someone Stumbling upon this, Read this first.
The one who posted this question was close but...
The concise answer
RButton::
if GetKeyState("LButton", "P")
Click Middle
else
Click r
Return
Upvotes: 1
Reputation: 383
Okay, I solved it in the most convoluted way possible. If you have a cleaner approach to this, please do give it to me because I don't feel comfortable with this but it works so heh.
middleclick := False
leftclick := False
rightclick := False
Loop {
If (GetKeyState("LButton", "P") && GetKeyState("RButton", "P") && !middleclick) {
middleclick := True
BlockInput, Mouse
Click Middle
SetTimer, middleclickfalse, -1000
} Else If (GetKeyState("LButton", "P") && !leftclick && !middleclick) {
leftclick := True
Click down
} Else If (GetKeyState("RButton", "P") && !rightclick && !middleclick) {
rightclick := True
Click down right
}
Sleep, 10
}
middleclickfalse:
middleclick := False
Return
LButton up::
If (!middleclick) {
If (leftclick) {
Click up
leftclick := False
}
}
Return
RButton up::
If (!middleclick) {
If (rightclick) {
Click up right
rightclick := False
}
}
Return
Upvotes: 2