1
votes

Similar to my other question: AHK script to turn hold buttons into toggle buttons but now I'd like to do the opposite.

I want it so as you hold down a key it will trigger an up/down and when you release it will again trigger an up/down.

I'm thinking something like this:

LShift down::
    send, {Capslock}

LShift up::
    send, {Capslock}

But I'm not sure on the LShift down:: part I'm pretty sure that won't work, so how can I do something that's effectively the same?

Note: I'm intending to use this for a game so instead of sending Capslock it should ideally send LShift as well, which I think may affect something. But if that's harder then I can just rebind sprint to something other than LShift

1

1 Answers

1
votes

Toggle keys are handled differently and use their own commands, read more here

Solution:

LShift::
    While (GetKeyState("LShift", "P"))
        SetCapslockState, On   
    SetCapslockState, Off
Return

Due to new information, solution #2:

LShift::
    While (GetKeyState("LShift", "P"))
        Send, {Capslock Down}  
    Send, {Capslock Up}
Return