Binding 2 keys to one action.

Ask gaming related questions (AHK v1.1 and older)
hockypockies
Posts: 3
Joined: 31 Jul 2022, 02:21

Binding 2 keys to one action.

Post by hockypockies » 31 Jul 2022, 02:25

I want to bind 2 keys, for example I and O to an action.

This is so I dont need to work as much for a specific game that I'm playing.

I::
sleep 10
send {LButton}
sleep 10
send {1}

However, I want to have O do the same thing, and preferably in an elegant way. I don't know how to do this, thanks!

hockypockies
Posts: 3
Joined: 31 Jul 2022, 02:21

Re: Binding 2 keys to one action.

Post by hockypockies » 31 Jul 2022, 02:31

I just realized this is in Gaming instead of AutoHotkey help. My bad.

gregster
Posts: 9014
Joined: 30 Sep 2013, 06:48

Re: Binding 2 keys to one action.

Post by gregster » 31 Jul 2022, 02:36

But this is for a game you were saying...?!
'Gaming' is just a subforum of 'Ask For Help', so that shouldn't be a problem. People will also help with topics posted here.
But games often have different requirements (eg Send options) than normal apps. So I guess this could be the right place.
(Although you could argue that this question has a general scope, if I understand it correctly. Let's see how it develops - we can still move it.)

gregster
Posts: 9014
Joined: 30 Sep 2013, 06:48

Re: Binding 2 keys to one action.

Post by gregster » 31 Jul 2022, 02:38

You can simply "stack" multiple hotkey labels that should run the same subroutine.
Is that what you are asking?

Code: Select all

i::		; press i
o::		; press o
sleep 10
send {LButton}
sleep 10
send {1}
return	; don't forget a return at the end of the subroutine

hockypockies
Posts: 3
Joined: 31 Jul 2022, 02:21

Re: Binding 2 keys to one action.

Post by hockypockies » 06 Oct 2022, 20:29

This seems to be good, thank you!
I didn't know you can stack keys like that, thanks for the information! You guys are pretty helpful.

Post Reply

Return to “Gaming Help (v1)”