R input on release

Ask gaming related questions (AHK v1.1 and older)
WilNot
Posts: 25
Joined: 14 Sep 2022, 08:00

R input on release

Post by WilNot » 06 Dec 2022, 06:34

Hello everyone, below this text is a script that I use to make it so that R acts normal but also presses R when I release it. But how can I make it so that it also does the same when I use !^m::r?

Code: Select all

R::
Send, {R}
KeyWait, R
Send, {R}
return

User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: R input on release

Post by boiler » 06 Dec 2022, 06:51

Try this:

Code: Select all

!^m::r

r::
Send, R ; do you really mean to send a shifted R?
KeyWait, r
KeyWait, m
Send, R ; same
return

I took out where you don’t need capital letters and braces. I question if you need the capital letters that are still there. It’s best to use lower case if you don’t mean to send a Shift along with the letter.

WilNot
Posts: 25
Joined: 14 Sep 2022, 08:00

Re: R input on release

Post by WilNot » 06 Dec 2022, 09:40

For some reason when I make the letters below r:: non-capital the script doesn't work. I changed some hotkeys by the way, this is what I use now:

Code: Select all

<^<!b::r
r::
Send, R
KeyWait, R
KeyWait, B
Send, R
return
Holding <^<!b still won't make R behave like it is supposed to though.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: R input on release

Post by mikeyww » 06 Dec 2022, 09:45

To trigger one subroutine with multiple hotkeys, you can simply stack the hotkeys, instead of creating separate subroutines. If the subroutine sends the hotkey itself, you can use the hook to avoid triggering a loop.

Explained: Dollar
This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. The $ prefix is equivalent to having specified #UseHook somewhere above the definition of this hotkey.

WilNot
Posts: 25
Joined: 14 Sep 2022, 08:00

Re: R input on release

Post by WilNot » 06 Dec 2022, 11:51

Sorry Mikey, I don't understand words like subroutine, do you wanna explain what you've said like I am 5?

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: R input on release

Post by mikeyww » 06 Dec 2022, 12:01

I did the search for you like you are 5, too: https://reimaginingeducation.org/what-is-a-subroutine/

Below is an idea.

Code: Select all

<^<!b::
$r::
Send r
KeyWait, r
KeyWait, b
Send r
Return
When I referred to the dollar, I was applying what is described in the documentation, regarding using $ as a hotkey modifier symbol, to avoid having Send r trigger the same section of code.

When I referred to stacking the hotkeys, I meant putting one "on top" of the other, as shown, so that both hotkeys trigger the same section of code.

It works as far as I can tell!

WilNot
Posts: 25
Joined: 14 Sep 2022, 08:00

Re: R input on release

Post by WilNot » 06 Dec 2022, 13:59

Good job, my slave! You are dismissed. :thumbup:

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: R input on release

Post by mikeyww » 06 Dec 2022, 15:17

But I am only at your service, my Liege. :wave:

Post Reply

Return to “Gaming Help (v1)”