Search code examples
mouseautohotkeymedia-player

Autohotkey Multiple hotkeys at same time (Middle button, Left button, Right button of the mouse pressed at once)


I'v been working on a way to controll music/media with my mouse, so far i can do all these:

Middle and Right button play next song

Mbutton & RButton::Send {Media_Next}

Middle and Left button play Previus song

Mbutton & LButton::Send {Media_Prev}

Middle pressed and rolled Up Increases sound (doesnt stop the use of middle click elsewhere)

Middle pressed and rolled Down Decreases sound (doesnt stop the use of middle click elsewhere)

#IfWinActive

Mbutton up::

`if a_priorhotkey not in wheelup,wheeldown`

    `send {Mbutton}`
return

#if getkeystate("Mbutton", "p")

Wheelup::Send {Volume_Up}

Wheeldown::Send {Volume_Down}

But now i need to press ALL 3 (Lbutton + Mbutton + Rbutton) at the same time, to send {Media_Play_Pause} And its not working with Lbutton & Mbutton & Rbutton...

Any ideas? Thanks for reading.


Solution

  • Here is a possibility:

    #if getkeystate("Lbutton", "p") and getkeystate("Rbutton", "p")
    MButton::Send {Media_Play_Pause}
    #if
    

    Explanation (albeit mostly straightforeword):

    1. Line 1: If the LButton and RButton are pressed
    2. Line 2: MButton means Send Media Pause/ Play
    3. Line 3: End context sensitive hotkeys

    Full Script:

    #IfWinActive
    
    Mbutton & RButton::Send {Media_Next}
    Mbutton & LButton::Send {Media_Prev}
    
    Mbutton up::
    if a_priorhotkey not in wheelup,wheeldown
    
        send {Mbutton}
    return
    
    #if getkeystate("Mbutton", "p")
    Wheelup::Send {Volume_Up}
    Wheeldown::Send {Volume_Down}
    
    #if getkeystate("Lbutton", "p") and getkeystate("Rbutton", "p")
    MButton::Send {Media_Play_Pause}
    #if