0
votes

In Windows Explorer I want to do the following:

When I press down and hold Mouse-Right: Autohotkey Wait for Mouse-Left click Run Action

When I Press down but release Mouse-Right (normal right click): Run normal Windows contect menu

The problem lies within the keystates of the mousebuttons. I cant figure it out. Maybe someone already has a similar script to this.

#IfWinActive ahk_class CabinetWClass
RButton::
Loop
{
   GetKeyState, state, RButton
   if state = D
     KeyWait, LButton, D
     send {Del}
   if state = U
     return
  }
 Click right
return

This is what i came up with. Not working :((

2

2 Answers

1
votes

Hope it helps.

#IfWinActive ahk_class CabinetWClass
RButton::
    While GetKeyState("RButton", "P")       ; while Rbutton is held down
        if GetKeyState("LButton", "P") {        ; if Lbutton is pressed
            GoSub, LabelAction 
            Return
        }
    SendInput {RButton}
return
#IfWinActive

LabelAction:
    msgbox, 64, % A_ThisLabel, Do some actions here.
Return
1
votes

I think that I have a bit nicer solution for this problem. It's shorter and cleaner in my opinion:

#IfWinActive ahk_class CabinetWClass

RButton & LButton::
    Send {Del} ;or do whatever you want
return

RButton::
    Send, {RButton}
return

Edit:

Looking back at this answer two and a half years later I have now realized that it probably prevents right click dragging of files, so this could potentially be a better alternative, but I haven't tested it:

#IfWinActive ahk_class CabinetWClass

~RButton & ~LButton::
    Send {Del} ;or do whatever you want
return