0

I am trying to make a script that when you hold the side mouse button it will keep pressing U, and when I let go of the side button it will stop pressing.

Here is what I have

RepeatKey := !RepeatKey
If RepeatKey
    SetTimer, SendTheKey, 100
Else
    SetTimer, SendTheKey, Off
return

p::
Pause
Suspend
return

SendTheKey:
SendInput u
Return

Right now this code is toggled it just keep pressing U until I press the side mouse button again Anyone know how to make it into a hold and release?

1

I've always done it like this. I don't know what mouse key you're using, but for this example I'll use XButton2 which would be the browser back button on a mouse.

If you want a sleep for a 100ms, add Sleep, 100 after your SendInput command.

XButton2::
KeyDown := !KeyDown
If KeyDown
    SendInput {u down}
    Sleep, 100
Else
    SendInput {u up}
Return
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.