Search code examples
autohotkeykeymapping

Map same key twice : Auto Hotkey


Is there any way to map a key twice using AHK? My code is the following:

loop
{
    GetKeyState, state, Alt
    if state = U
    {
        RButton::t
    }
    else
    {
        RButton::RButton
    }
}

I get an error "Error: Duplicate hotkey" for trying to map twice my RButton.

What I wanna do here is pretty simple ; I want my RButton to become 't' when 'alt' is not pressed and I want it back to RButton when 'alt' is pressed.

Thank you

Edit: I don't want:

!RButton::t

I want:

RButton::t
!RButton::RButton

But it is not working either.


Solution

  • exactly

    RButton::t
    !RButton::RButton
    

    should actually work, not sure why it doesn't.

    Anway,

    RButton::
        send t
    return
    
    !RButton::
        click right
    return
    

    works.